Background

Interruption API This problem isn’t new to fibers. On the thread domain the usual approaches are: (Windows) Every time you block on a thread, do it using WaitForMultipleObjects so another thread might signal you to stop your activity and exit earlier. It’s verbose and boring and error-prone and also require extra non-standard communcation protocols/idioms between every spawned thread and the killer thread. Bad as it is, this style hasn’t died. [Read More]

Interruption

If a fiber is stalled waiting for some IO request that might never complete you still can use the interruption API to stop the fiber. The fiber interruption API was inspired by the POSIX thread cancellation API (and Boost.Thread)[1]. Interrupting a fiber If you want to interrupt a fiber, call fiber::interrupt(). An interruption request will be queued for near delivery to interrupt the fiber. The fiber will react to the interruption request when it next calls a function that is a suspension point (or if it is currently suspended whilst executing one). [Read More]

IOFiber

Fibers are lightweight threads managed in user-space. Fibers from this library are: Stackful. Cooperative. Use Boost.Asio execution contexts (e.g. boost::asio::io_context) as schedulers. Any async function will work as a suspension point. Non-symmetric. Main fiber and secondary fibers are exposed to different APIs. There is a clear separation between fibers that run inside and outside ASIO’s execution contexts. trial::iofiber::fiber is an alias for trial::iofiber::basic_fiber<boost::asio::io_context::strand>. [Read More]