[exec.sysctxrepl.psb]

# 33 Execution control library [[exec]](./#exec)

## 33.16 Namespace system_context_replaceability [[exec.sysctxrepl]](exec.sysctxrepl#psb)

### 33.16.3 Class parallel_scheduler_backend [exec.sysctxrepl.psb]

namespace std::execution::system_context_replaceability {struct [parallel_scheduler_backend](#lib:parallel_scheduler_backend "33.16.3 Class parallel_­scheduler_­backend [exec.sysctxrepl.psb]") {virtual ~parallel_scheduler_backend() = default; virtual void schedule(receiver_proxy&, span<byte>) noexcept = 0; virtual void schedule_bulk_chunked(size_t, bulk_item_receiver_proxy&,
 span<byte>) noexcept = 0; virtual void schedule_bulk_unchunked(size_t, bulk_item_receiver_proxy&,
 span<byte>) noexcept = 0; };}

[ð](#lib:schedule,parallel_scheduler_backend)

`virtual void schedule(receiver_proxy& r, span<byte> s) noexcept = 0;
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L8550)

*Preconditions*: The ends of
the lifetimes of *this,
the object referred to by r, and
any storage referenced by s all happen after
the beginning of the evaluation of
the call to set_value, set_error, or set_done on r (see below)[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L8561)

*Effects*: A derived class shall implement this function such that:

- [(2.1)](#2.1)

  One of the following expressions is evaluated:
  * [(2.1.1)](#2.1.1)

r.set_value(), if no error occurs, and the work is successful;

  * [(2.1.2)](#2.1.2)

r.set_error(eptr), if an error occurs,
where eptr is an object of type exception_ptr;

  * [(2.1.3)](#2.1.3)

r.set_stopped(), if the work is canceled[.](#2.1.sentence-1)

- [(2.2)](#2.2)

  Any call to r.set_value() happens on
an execution agent of the execution context represented by *this[.](#2.2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L8581)

*Remarks*: The storage referenced by s may be used by *this as temporary storage
for the duration of the operation launched by this call[.](#3.sentence-1)

[ð](#lib:schedule_bulk_chunked,parallel_scheduler_backend)

`virtual void schedule_bulk_chunked(size_t n, bulk_item_receiver_proxy& r,
                                   span<byte> s) noexcept = 0;
`

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L8595)

*Preconditions*: The ends of
the lifetimes of *this,
the object referred to by r, and
any storage referenced by s all happen after
the beginning of the evaluation of one of the expressions below[.](#4.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L8604)

*Effects*: A derived class shall implement this function such that:

- [(5.1)](#5.1)

  Eventually, one of the following expressions is evaluated:
  * [(5.1.1)](#5.1.1)

r.set_value(), if no error occurs, and the work is successful;

  * [(5.1.2)](#5.1.2)

r.set_error(eptr), if an error occurs,
where eptr is an object of type exception_ptr;

  * [(5.1.3)](#5.1.3)

r.set_stopped(), if the work is canceled[.](#5.1.sentence-1)

- [(5.2)](#5.2)

  If r.execute(b, e) is called,
then b and e are in the range [0, n] andb < e[.](#5.2.sentence-1)

- [(5.3)](#5.3)

  For each i in [0, n),
there is at most one call to r.execute(b, e) such that i is in the range [b, e)[.](#5.3.sentence-1)

- [(5.4)](#5.4)

  If r.set_value() is called,
then for each i in [0, n),
there is exactly one call to r.execute(b, e) such that i is in the range [b, e)[.](#5.4.sentence-1)

- [(5.5)](#5.5)

  All calls to execute on r happen before
the call to either set_value, set_error, or set_stopped on r[.](#5.5.sentence-1)

- [(5.6)](#5.6)

  All calls to execute and set_value on r are made
on execution agents of the execution context represented by *this[.](#5.6.sentence-1)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L8641)

*Remarks*: The storage referenced by s may be used by *this as temporary storage for the duration of the operation launched by this call[.](#6.sentence-1)

[ð](#lib:schedule_bulk_unchunked,parallel_scheduler_backend)

`virtual void schedule_bulk_unchunked(size_t n, bulk_item_receiver_proxy& r,
                                     span<byte> s) noexcept = 0;
`

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L8654)

*Preconditions*: The ends of
the lifetimes of *this,
the object referred to by r, and
any storage referenced by s all happen after
the beginning of the evaluation of one of the expressions below[.](#7.sentence-1)

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L8663)

*Effects*: A derived class shall implement this function such that:

- [(8.1)](#8.1)

  Eventually, one of the following expressions is evaluated:
  * [(8.1.1)](#8.1.1)

r.set_value(), if no error occurs, and the work is successful;

  * [(8.1.2)](#8.1.2)

r.set_error(eptr), if an error occurs,
where eptr is an object of type exception_ptr;

  * [(8.1.3)](#8.1.3)

r.set_stopped(), if the work is canceled[.](#8.1.sentence-1)

- [(8.2)](#8.2)

  If r.execute(b, e) is called,
then b is in the range [0, n) ande is equal to b + 1[.](#8.2.sentence-1)
  For each i in [0, n),
there is at most one call to r.execute(i, i + 1)[.](#8.2.sentence-2)

- [(8.3)](#8.3)

  If r.set_value() is called,
then for each i in [0, n),
there is exactly one call to r.execute(i, i + 1)[.](#8.3.sentence-1)

- [(8.4)](#8.4)

  All calls to execute on r happen before
the call to either set_value, set_error, or set_stopped on r[.](#8.4.sentence-1)

- [(8.5)](#8.5)

  All calls to execute and set_value on r are made
on execution agents of the execution context represented by *this[.](#8.5.sentence-1)

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L8697)

*Remarks*: The storage referenced by s may be used by *this as temporary storage for the duration of the operation launched by this call[.](#9.sentence-1)
