cplusplus / sender-receiver

Issues list for P2300
Apache License 2.0
19 stars 3 forks source link

Add support for strand-schedulers #285

Open lewissbaker opened 1 month ago

lewissbaker commented 1 month ago

Some algorithms can have more efficient implementations if they know that the scheduler that they are scheduling work on can only ever execute one thing at a time. Algorithms can potentially avoid needing to perform synchronization if this is the case.

However, we don't yet have any way of querying on a scheduler whether tasks scheduled on that scheduler can potentially execute concurrently or not.

To facilitate this we should provide such a query. This could either take the form of an is_strand query on the scheduler, or potentially a more general max_concurrency query, which callers can then check to see if it's equal to 1.

There may be some cases where a particular algorithm requires a strand-scheduler. We should also consider adding an adapter for a scheduler that returns a new scheduler that is guaranteed to be a strand-scheduler.