Re: suspendable/resumable/prioritizable task dispatcher

chris-boostusers--- via Boost-users <[email protected]>
Newsgroups gmane.comp.lib.boost.user
Message-ID <[email protected]>
On 8/28/22 4:06 PM, Gavin Lambert via Boost-users wrote:
> 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

Gavin,

Thank you.  I had never heard of a "fiber" before but they are 
brilliant.  Coroutines without coroutines!

I ended up writing my own "algorithm" based on your suggestions.  I had 
to overcome these issues:

1. When using multiple threads (to run fibers in parallel), the 
boost-provided algorithms busy-wait when there is no work to do.  They 
have an option to suspend but they don't wake up to "steal" or "share" 
fibers from other threads.  So my algorithm has a mechanism to wake up 
idle threads when excess work appears on a non-idle thread.

2. I added "priority" so a high priority can preempt a lower priority fiber

3. boost::fibers::yield() needed a modification to handle priorities. If 
the highest priority fiber calls yield(), and there are only lower 
priority fibers, control will be yielded to a lower priority fiber -- 
without input from the "algorithm".  I would have preferred if the 
custom algorithm could have vetoed the context switch.  But instead I 
wrote my own yield that consulted with the algo.  This modification 
would have been easier if boost::fibers::scheduler::get_algo() were 
provided.

Anyhow, thanks again.  This is a wonderful library.

Chris
_______________________________________________
Boost-users mailing list
[email protected]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.