[saferecl.rcu.domain.func]

# 32 Concurrency support library [[thread]](./#thread)

## 32.11 Safe reclamation [[saferecl]](saferecl#rcu.domain.func)

### 32.11.2 Read-copy update (RCU) [[saferecl.rcu]](saferecl.rcu#domain.func)

#### 32.11.2.4 Class rcu_domain [[saferecl.rcu.domain]](saferecl.rcu.domain#func)

#### 32.11.2.4.3 Non-member functions [saferecl.rcu.domain.func]

[ð](#lib:rcu_default_domain)

`rcu_domain& rcu_default_domain() noexcept;
`

[1](#1)

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

*Returns*: A reference to a static-duration object of type rcu_domain[.](#1.sentence-1)

A reference to the same object is returned every time this function is called[.](#1.sentence-2)

[ð](#lib:rcu_synchronize)

`void rcu_synchronize(rcu_domain& dom = rcu_default_domain()) noexcept;
`

[2](#2)

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

*Effects*: If the call to rcu_synchronize does not strongly happen before
the lock opening an RCU protection region R on dom,
blocks until the unlock closing R happens[.](#2.sentence-1)

[3](#3)

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

*Synchronization*: The unlock closing R strongly happens before the return from rcu_synchronize[.](#3.sentence-1)

[ð](#lib:rcu_barrier)

`void rcu_barrier(rcu_domain& dom = rcu_default_domain()) noexcept;
`

[4](#4)

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

*Effects*: May evaluate any scheduled evaluations in dom[.](#4.sentence-1)

For any evaluation that happens before the call to rcu_barrier and
that schedules an evaluation E in dom,
blocks until E has been evaluated[.](#4.sentence-2)

[5](#5)

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

*Synchronization*: The evaluation of any such E strongly happens before the return from rcu_barrier[.](#5.sentence-1)

[*Note [1](#note-1)*:

A call to rcu_barrier does not imply
a call to rcu_synchronize and vice versa[.](#5.sentence-2)

â *end note*]

[ð](#lib:rcu_retire)

`template<class T, class D = default_delete<T>>
void rcu_retire(T* p, D d = D(), rcu_domain& dom = rcu_default_domain());
`

[6](#6)

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

*Mandates*: is_move_constructible_v<D> is true and
the expression d(p) is well-formed[.](#6.sentence-1)

[7](#7)

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

*Preconditions*: D meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") and[*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#7.sentence-1)

[8](#8)

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

*Effects*: May allocate memory[.](#8.sentence-1)

It is unspecified whether the memory allocation
is performed by invoking operator new[.](#8.sentence-2)

Initializes an object d1 of type D from std​::​move(d)[.](#8.sentence-3)

Schedules the evaluation of d1(p) in the domain dom;
the behavior is undefined if that evaluation exits via an exception[.](#8.sentence-4)

May invoke scheduled evaluations in dom[.](#8.sentence-5)

[*Note [2](#note-2)*:

If rcu_retire exits via an exception, no evaluation
is scheduled[.](#8.sentence-6)

â *end note*]

[9](#9)

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

*Throws*: bad_alloc or any exception thrown by the initialization of d1[.](#9.sentence-1)

[10](#10)

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

[*Note [3](#note-3)*:

If scheduled evaluations acquire resources
held across any invocation of rcu_retire on dom,
deadlock can occur[.](#10.sentence-1)

â *end note*]
