[exec.run.loop.types]

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

## 33.12 Execution contexts [[exec.ctx]](exec.ctx#exec.run.loop.types)

### 33.12.1 execution​::​run_loop [[exec.run.loop]](exec.run.loop#types)

#### 33.12.1.2 Associated types [exec.run.loop.types]

[ð](#itemdecl:1)

`class run-loop-scheduler;
`

[1](#1)

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

*run-loop-scheduler* is an unspecified type
that models [scheduler](exec.sched#concept:scheduler "33.6 Schedulers [exec.sched]")[.](#1.sentence-1)

[2](#2)

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

Instances of *run-loop-scheduler* remain valid
until the end of the lifetime of the run_loop instance
from which they were obtained[.](#2.sentence-1)

[3](#3)

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

Two instances of *run-loop-scheduler* compare equal
if and only if they were obtained from the same run_loop instance[.](#3.sentence-1)

[4](#4)

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

Let *sch* be an expression of type *run-loop-scheduler*[.](#4.sentence-1)

The expression schedule(*sch*) has type *run-loop-  
sender* and
is not potentially-throwing if *sch* is not potentially-throwing[.](#4.sentence-2)

[ð](#itemdecl:2)

`class run-loop-sender;
`

[5](#5)

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

*run-loop-sender* is an exposition-only type
that satisfies [sender](exec.snd.concepts#concept:sender "33.9.3 Sender concepts [exec.snd.concepts]")[.](#5.sentence-1)

completion_signatures_of_t<*run-  
loop-sender*> iscompletion_signatures<set_value_t(), set_error_t(exception_ptr), set_stopped_t()>

[6](#6)

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

An instance of *run-loop-sender* remains valid
until the end of the lifetime of its associated run_loop instance[.](#6.sentence-1)

[7](#7)

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

Let *sndr* be an expression of type *run-loop-sender*,
let *rcvr* be an expression
such that [receiver_of](exec.recv.concepts#concept:receiver_of "33.7.1 Receiver concepts [exec.recv.concepts]")<decltype((*rcvr*)), CS> is true where CS is the completion_signatures specialization above[.](#7.sentence-1)

Let C be either set_value_t or set_stopped_t[.](#7.sentence-2)

Then:

- [(7.1)](#7.1)

  The expression connect(*sndr*, *rcvr*) has type *run-loop-opstate*<decay_t<decltype((*rcvr*))>> and is potentially-throwing if and only if(void(*sndr*), auto(*rcvr*)) is potentially-throwing[.](#7.1.sentence-1)

- [(7.2)](#7.2)

  The expression get_completion_scheduler<C>(get_env(*sndr*)) is potentially-throwing if and only if *sndr* is potentially-throwing,
has type *run-loop-scheduler*, and
compares equal to the *run-loop-  
scheduler* instance
from which *sndr* was obtained[.](#7.2.sentence-1)

[ð](#itemdecl:3)

`template<class Rcvr>
  struct run-loop-opstate;
`

[8](#8)

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

*run-loop-opstate*<Rcvr> inherits privately and unambiguously from *run-loop-opstate-base*[.](#8.sentence-1)

[9](#9)

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

Let o be a non-const lvalue of type *run-loop-opstate*<Rcvr>,
and let REC(o) be a non-const lvalue reference to an instance of type Rcvr that was initialized with the expression *rcvr* passed to the invocation of connect that returned o[.](#9.sentence-1)

Then:

- [(9.1)](#9.1)

The object to which *REC*(o) refers
remains valid for the lifetime of the object to which o refers.

- [(9.2)](#9.2)

The type *run-loop-opstate*<Rcvr> overrides*run-loop-opstate-base*​::​*execute*() such that o.*execute*() is equivalent to:if (get_stop_token(*REC*(o)).stop_requested()) { set_stopped(std::move(*REC*(o)));} else { set_value(std::move(*REC*(o)));}

- [(9.3)](#9.3)

The expression start(o) is equivalent to:try {o.*loop*->*push-back*(addressof(o));} catch(...) { set_error(std::move(*REC*(o)), current_exception());}
