No need to use any protobuf protocol to pass data between threads?
You’re asking why do you need to use the endpoints because all of the components are running in the same process? If I understood the question, then it because you can reconfigure components to run in separate processes too, so we make no assumptions. Even intraprocess communication with a shared address space you want your reading/writing to be controlled. With Cap’n Proto (and FlatBuffers, for example), the in-memory representation is the serialization format, so you aren’t marshalling together your data structure when you need to “send” it anywhere, even to just the next thread over.
I agree that we should use some protobuf tech to pass data between processes even between two different machines, but if two compoents are in the same process, if we use protobuf tech, it will add some overhead cost caused by serilization and deserialization, right? Is it better if we pass data pointers in this condition?
You’re right, of course, but there is no overhead for serialization/deserialization for Cap’n Proto (or FlatBuffers) since the in-memory format is the serialization format, and with protobufs in this manner, you can either configure components in the same process or not and it is transparent from the component’s point of view.
You mean Cap`n proto does not need to do serialization/deserialization, right? That is the reason why you choose capnp instead of Google protobuf which definitely do serialization/deserialization, correct me if I am wrong, ：）.