33 Execution control library [exec]

33.15 Parallel scheduler [exec.par.scheduler]

parallel_scheduler models scheduler.
Let sch be an object of type parallel_scheduler, and let BACKEND-OF(sch) be *ptr, where sch is associated with ptr.
The expression get_forward_progress_guarantee(sch) returns forward_progress_guarantee​::​parallel.
Let sch2 be an object of type parallel_scheduler.
Two objects sch and sch2 compare equal if and only if BACKEND-OF(sch) and BACKEND-OF(sch2) refer to the same object.
Let rcvr be a receiver.
A proxy for rcvr with base B is an lvalue r of type B such that:
  • r.set_value() has effects equivalent to set_value(std​::​move(rcvr)).
  • r.set_error(e), where e is an exception_ptr object, has effects equivalent to set_error(std​::​move(​rcvr), std​::​move(e)).
  • r.set_stopped() has effects equivalent to set_stopped(std​::​move(rcvr)).
A preallocated backend storage for a proxy r is an object s of type span<byte> such that the range s remains valid and may be overwritten until one of set_value, set_error, or set_stopped is called on r.
[Note 1: 
The storage referenced by s can be used as temporary storage for operations launched via calls to parallel_scheduler_backend.
— end note]
A bulk chunked proxy for rcvr with callable f and arguments args is a proxy r for rcvr with base system_context_replaceability​::​bulk_item_receiver_proxy such that r.execute(i, j) for indices i and j has effects equivalent to f(i, j, args...).
A bulk unchunked proxy for rcvr with callable f and arguments args is a proxy r for rcvr with base system_context_replaceability​::​bulk_item_receiver_proxy such that r.execute(i, i + 1) for index i has effects equivalent to f(i, args...).
Let b be BACKEND-OF(sch), let sndr be the object returned by schedule(sch), and let rcvr be a receiver.
If rcvr is connected to sndr and the resulting operation state is started, then:
  • If sndr completes successfully, then b.schedule(r, s) is called, where
    • r is a proxy for rcvr with base system_context_replaceability​::​receiver_proxy and
    • s is a preallocated backend storage for r.
  • All other completion operations are forwarded unchanged.
parallel_scheduler provides a customized implementation of the bulk_chunked algorithm ([exec.bulk]).
If a receiver rcvr is connected to the sender returned by bulk_chunked(sndr, pol, shape, f) and the resulting operation state is started, then:
  • If sndr completes with values vals, let args be a pack of lvalue subexpressions designating vals, then b.schedule_bulk_chunked(shape, r, s) is called, where
    • r is a bulk chunked proxy for rcvr with callable f and arguments args and
    • s is a preallocated backend storage for r.
  • All other completion operations are forwarded unchanged.
[Note 2: 
Customizing the behavior of bulk_chunked affects the default implementation of bulk.
— end note]
parallel_scheduler provides a customized implementation of the bulk_unchunked algorithm ([exec.bulk]).
If a receiver rcvr is connected to the sender returned by bulk_unchunked(sndr, pol, shape, f) and the resulting operation state is started, then:
  • If sndr completes with values vals, let args be a pack of lvalue subexpressions designating vals, then b.schedule_bulk_unchunked(shape, r, s) is called, where
    • r is a bulk unchunked proxy for rcvr with callable f and arguments args and
    • s is a preallocated backend storage for r.
  • All other completion operations are forwarded unchanged.
parallel_scheduler get_parallel_scheduler();
Effects: Let eb be the result of system_context_replaceability​::​query_parallel_scheduler_backend().
If eb == nullptr is true, calls terminate ([except.terminate]).
Otherwise, returns a parallel_scheduler object associated with eb.