That would be one way to do it. Make sure to use Unix sockets as they are
much more efficient than TCP.

That said, writing the messages out to a socket and reading it back in is
still a bit silly for inter-thread communication, where the target thread
could just read the message from memory. Unfortunately the capnp library
doesn't currently include code for efficient inter-thread RPC. I've been
meaning to write a new implementation of VatNetwork using kj::Executor for
inter-thread comms but haven't had the chance yet.

So for now, what I'd actually recommend for inter-thread communications is
to use kj::Executor directly. This lets you run an arbitrary lambda on
another thread and have the result sent back to the calling thread.

Probably I should update the doc to not suggest inter-thread RPC until it's
actually implemented... :)

-Kenton

On Wed, May 20, 2020 at 2:54 AM YY Dragon <[email protected]> wrote:

> as https://capnproto.org/cxxrpc.html say KJ discourages fine-grained
> interaction between threads as synchronization is expensive and
> error-prone. Instead, threads are encouraged to communicate through Cap’n
> Proto RPC.
> I have question , how can I ues rpc for threads communicate?
> should I instantiate a capnp::EzRpcServer on each thread?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Cap'n Proto" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/capnproto/8a3a68cb-7a4d-45e0-b7c6-2a7456d34a91%40googlegroups.com
> <https://groups.google.com/d/msgid/capnproto/8a3a68cb-7a4d-45e0-b7c6-2a7456d34a91%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/capnproto/CAJouXQm4hqJ8-pz4fidp-Cop3WN1wmi_K7RRNF2O1NMWnK6x4g%40mail.gmail.com.

Reply via email to