Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. Any *Sender* type, `S`, that has `sender_traits<S>::is_always_scheduler_affine` set to `true` will be returned unmodified from `with_scheduler_affinity`. For *Senders* that are not always *Scheduler*-affine and that do not customize `with_scheduler_affinity`, the default implementation is: ``` template <typename Sender, typename Scheduler> auto with_scheduler_affinity(Sender&& s, Scheduler&& sched) { return finally( std::forward<Sender>(s), unstoppable(schedule(std::forward<Scheduler>(sched)))); } ```
- Loading branch information