-
Kenton Varda authored
Fibers allow code to be written in a synchronous / blocking style while running inside the KJ event loop, by executing the code on an alternate call stack and switching back to the main stack whenever it waits. We introduce a new function, `kj::startFiber(stackSize, func)`. `func` is executed on the fiber stack. It is passed as its parameter a `WaitScope&`, which can then be passed into the `.wait()` method of any promise in order to wait on the promise in a blocking style. `startFiber()` returns a promise for the eventual value returned by `func()` (much as `evalLater()` and friends do). This commit implements fibers on Unix via ucontext_t. Windows will come next (and will probably be easier...).
e8a14a7a
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
benchmark | ||
capnp | ||
kj | ||
CMakeLists.txt |