Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reimplement scheduler affinity (#527)
This diff changes how `unifex::task<>` implements *Scheduler* affinity to work more like `folly::coro::Task<>`. What Folly calls `co_viaIfAsync`, this diff calls `with_scheduler_affinity`, which is a new CPO. `with_scheduler_affinity` is a *Sender* algorithm that maps the given *Sender* to another *Sender* that must meet new postconditions if the *Receiver* that it's connected to meets certain preconditions. The new preconditions are: - the eventual *Receiver* must provide a "current *Scheduler*"; - the result of `with_scheduler_affinity` must be started on the *Receiver's* current *Scheduler*; and - stop requests delivered to the new *Sender* must be delivered on the *Receiver's* current *Scheduler*. The *Sender* returned from `with_scheduler_affinity` must complete on its *Receiver's* current *Scheduler* (i.e. must complete where it was started) so long as all the above preconditions are met. `with_scheduler_affinity` has two default implementations for a _Sender_ type `S`: - if `sender_traits<S>::is_always_scheduler_affine` is `true`, the default is the identity; - if `sender_traits<S>::is_always_scheduler_affine` is `false`, the default is, essentially, a `typed_via` back to the correct scheduler. Any _Sender_ can customize `with_scheduler_affinity`, regardless of its `is_always_scheduler_affine` property.
- Loading branch information