Extend KJ event loop to support cross-thread events.
The new `Executor` class provides an interface to run a function on some other thread's EventLoop. `kj::getCurrentThreadExecutor()` gets a reference to this thread's executor, which can then be exposed to other threads. When a thread requests execution of a function on another thread, the return value is returned to the requesting thread. The requesting thread may choose to wait synchronously for this return value or -- if the requesting thread has an event loop of its own -- it can get Promise for the eventual result. Meanwhile, orthogonally, the function can either return a raw result or return a Promise; in the latter case, the Promise is resolved to completion in the executor thread and the final result is sent back to the requesting thread.
Showing
This diff is collapsed.
Please
register
or
sign in
to comment