From Jason Turner

[thread.once.callonce]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpi_tzwh_5/{from.md → to.md} +23 -16
tmp/tmpi_tzwh_5/{from.md → to.md} RENAMED
@@ -3,39 +3,44 @@
3
  ``` cpp
4
  template<class Callable, class... Args>
5
  void call_once(once_flag& flag, Callable&& func, Args&&... args);
6
  ```
7
 
8
- *Requires:* `Callable` and each `Ti` in `Args` shall satisfy the
9
- `MoveConstructible` requirements. *`INVOKE`*`(`*`DECAY_COPY`*`(`
10
- `std::forward<Callable>(func)), `*`DECAY_COPY`*`(std::forward<Args>(args))...)`
11
- ([[func.require]]) shall be a valid expression.
 
 
 
12
 
13
  *Effects:* An execution of `call_once` that does not call its `func` is
14
  a *passive* execution. An execution of `call_once` that calls its `func`
15
- is an *active* execution. An active execution shall call
16
- *`INVOKE`*`(`*`DECAY_COPY`*`(`
17
- `std::forward<Callable>(func)), `*`DECAY_COPY`*`(std::forward<Args>(args))...)`.
18
- If such a call to `func` throws an exception the execution is
19
- *exceptional*, otherwise it is *returning*. An exceptional execution
20
- shall propagate the exception to the caller of `call_once`. Among all
21
- executions of `call_once` for any given `once_flag`: at most one shall
22
- be a returning execution; if there is a returning execution, it shall be
23
- the last active execution; and there are passive executions only if
24
- there is a returning execution. passive executions allow other threads
25
- to reliably observe the results produced by the earlier returning
26
- execution.
27
 
28
  *Synchronization:* For any given `once_flag`: all active executions
29
  occur in a total order; completion of an active execution synchronizes
30
  with ([[intro.multithread]]) the start of the next one in this total
31
  order; and the returning execution synchronizes with the return from all
32
  passive executions.
33
 
34
  *Throws:* `system_error` when an exception is
35
  required ([[thread.req.exception]]), or any exception thrown by `func`.
36
 
 
 
37
  ``` cpp
38
  // global flag, regular function
39
  void init();
40
  std::once_flag flag;
41
 
@@ -60,5 +65,7 @@ class information {
60
  public:
61
  void verify() { std::call_once(verified, &information::verifier, *this); }
62
  };
63
  ```
64
 
 
 
 
3
  ``` cpp
4
  template<class Callable, class... Args>
5
  void call_once(once_flag& flag, Callable&& func, Args&&... args);
6
  ```
7
 
8
+ *Requires:*
9
+
10
+ ``` cpp
11
+ INVOKE(std::forward<Callable>(func), std::forward<Args>(args)...)
12
+ ```
13
+
14
+ (see [[func.require]]) shall be a valid expression.
15
 
16
  *Effects:* An execution of `call_once` that does not call its `func` is
17
  a *passive* execution. An execution of `call_once` that calls its `func`
18
+ is an *active* execution. An active execution shall call *INVOKE*(
19
+ std::forward\<Callable\>(func), std::forward\<Args\>(args)...). If such
20
+ a call to `func` throws an exception the execution is *exceptional*,
21
+ otherwise it is *returning*. An exceptional execution shall propagate
22
+ the exception to the caller of `call_once`. Among all executions of
23
+ `call_once` for any given `once_flag`: at most one shall be a returning
24
+ execution; if there is a returning execution, it shall be the last
25
+ active execution; and there are passive executions only if there is a
26
+ returning execution.
27
+
28
+ [*Note 1*: Passive executions allow other threads to reliably observe
29
+ the results produced by the earlier returning execution. — *end note*]
30
 
31
  *Synchronization:* For any given `once_flag`: all active executions
32
  occur in a total order; completion of an active execution synchronizes
33
  with ([[intro.multithread]]) the start of the next one in this total
34
  order; and the returning execution synchronizes with the return from all
35
  passive executions.
36
 
37
  *Throws:* `system_error` when an exception is
38
  required ([[thread.req.exception]]), or any exception thrown by `func`.
39
 
40
+ [*Example 1*:
41
+
42
  ``` cpp
43
  // global flag, regular function
44
  void init();
45
  std::once_flag flag;
46
 
 
65
  public:
66
  void verify() { std::call_once(verified, &information::verifier, *this); }
67
  };
68
  ```
69
 
70
+ — *end example*]
71
+