Capnproto RPC, processing of IPC calls

Skip to first unread message

Lena_work Work

Dec 2, 2020, 9:48:46 AM12/2/20
to Cap'n Proto

I'm working on a project where rpc calls and other processing must occur in the same thread. That thread may only be interrupted for short periods. To achieve this I'm thinking about adding a file descriptor of the IPC to the poller in our code. When data is available on this file descriptor IPC calls will be processed until either there are none left or the allowed time is up.

The class `EventLoop` has a function `run` that is described to be doing what seems useful in my case. For this reason it would be helpful to know how I can set up an rpc server with an eventloop that I can interact with directly?
Any alternative suggestions would also be greatly appreciated.

- Lena

Kenton Varda

Dec 2, 2020, 3:56:13 PM12/2/20
to Lena_work Work, Cap'n Proto
Hi Lena,

`WaitScope` has a method called `poll()` which checks for new I/O and handles it without blocking. Maybe you can get away with calling that from time to time.

If that doesn't work, then it sounds like you may need to implement your own kj::EventPort to use in place of kj::UnixEventPort. A custom event allows you to integrate with some other event loop. You will end up needing to implement your own AsyncIoStream based on this. For an example of something similar, you could look at how node-capnp implements a custom event port that uses libuv's event loop (in order to integrate with Node); see the first part of this file:

Obviously, that's a fair amount of work, so hopefully the `poll()` approach gets you what you want.


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
To view this discussion on the web visit


Dec 7, 2020, 3:17:45 AM12/7/20
to Cap'n Proto
Hi Kenton,

Thanks for the quick response and direction. The example comes in handy as I am opting for the longer route.

- Lena

Lena Lötter

Dec 7, 2020, 11:20:15 AM12/7/20
to Cap'n Proto
Thanks for the quick response and direction. The example comes in handy as I opted for the longer route.

On Wednesday, December 2, 2020 at 10:56:13 PM UTC+2 wrote:

Kenton Varda

Dec 7, 2020, 11:24:26 AM12/7/20
to Cap'n Proto
(Dupe message happened because one got stuck in the moderation queue.)

Reply all
Reply to author
0 new messages