On 29/08/2022 01:58, chris-boostusers wrote:
I have a list of CPU-bound tasks I need to perform. I'll list two of them here:
a) compute first zillion digits of pi (low priority) b) add two plus two (high priority)
I co_spawn (a). Later, while (a) is running, I co_spawn (b). (a) will be suspended at a "co_suspension_point" so that (b) can take over. Of course when (b) completes, (a) will resume.
For bonus points, it will support multiple threads (probably easy) and a task's priority can change over time (probably hard).
Scheduling coroutines is in Boost.Fiber's wheelhouse. I don't think it provides a priority-based scheduler out of the box, but it does discuss it as a customisation point at: https://www.boost.org/doc/libs/1_80_0/libs/fiber/doc/html/fiber/scheduling.h...