Category : boost-fiber

I was experimenting with boost asio with fibers and found that boost::this_fiber::yield() and boost::this_fiber::sleep_for(x) seem to behave differently when using the round robin asio scheduler provided in fibers examples. The setup is that we have one thread create two fibers which loop indefinitely: Fiber 1 uses async read with a beast websocket. while (true) { ..

Read more

I would like to resume boost fibers across threads. Unfortunately I couldn’t find anything helpful in boost fibers documentation, even at the "Migrating fibers between threads" paragraph. Sample code: #include <iostream> #include <future> #include <boost/fiber/all.hpp> #include <chrono> int main() { boost::fibers::fiber myfiber{[]() { while(true) { // Long running fiber std::cerr << std::this_thread::get_id() << std::endl; boost::this_fiber::sleep_for(std::chrono::seconds{1}); ..

Read more