|
Boost : |
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2023-09-27 20:12:29
Dear Boost,
At work I need to move a Boost Fiber from one kernel thread to another.
There is a dedicated documentation page for this:
https://www.boost.org/doc/libs/1_83_0/libs/fiber/doc/html/fiber/migration.html
What that page doesn't say is how to migrate yourself if you're
currently within a Fiber to another kernel thread, as the docs only talk
about migrating Fibers currently not executing and in the ready not
sleeping state. I guess this would work:
1. Create a new Fiber, and go into a loop giving up the current execution.
2. When that new Fiber executes, migrate the original fiber to its new
kernel thread, then have it exit the loop so it proceeds. Then self
immolate, as you're done.
But now you're creating and destroying a whole Fiber just to migrate a
Fiber between kernel threads, and that feels icky.
I don't suppose there's a better way e.g. some sort of way of asking the
current thread's Fiber scheduler to call a function when it's next not
executing a Fiber? That would avoid the needless Fiber creation and
destruction per migration of a Fiber across kernel threads.
Thanks for help in advance.
Niall
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk