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
|
| 1 |
+
#### Simple Counting Scope <a id="exec.scope.simple.counting">[[exec.scope.simple.counting]]</a>
|
| 2 |
+
|
| 3 |
+
##### General <a id="exec.scope.simple.counting.general">[[exec.scope.simple.counting.general]]</a>
|
| 4 |
+
|
| 5 |
+
``` cpp
|
| 6 |
+
namespace std::execution {
|
| 7 |
+
class simple_counting_scope {
|
| 8 |
+
public:
|
| 9 |
+
// [exec.simple.counting.token], token
|
| 10 |
+
struct token;
|
| 11 |
+
|
| 12 |
+
static constexpr size_t max_associations = implementation-defined;
|
| 13 |
+
|
| 14 |
+
// [exec.simple.counting.ctor], constructor and destructor
|
| 15 |
+
simple_counting_scope() noexcept;
|
| 16 |
+
simple_counting_scope(simple_counting_scope&&) = delete;
|
| 17 |
+
~simple_counting_scope();
|
| 18 |
+
|
| 19 |
+
// [exec.simple.counting.mem], members
|
| 20 |
+
token get_token() noexcept;
|
| 21 |
+
void close() noexcept;
|
| 22 |
+
sender auto join() noexcept;
|
| 23 |
+
|
| 24 |
+
private:
|
| 25 |
+
size_t count; // exposition only
|
| 26 |
+
scope-state-type state; // exposition only
|
| 27 |
+
|
| 28 |
+
bool try-associate() noexcept; // exposition only
|
| 29 |
+
void disassociate() noexcept; // exposition only
|
| 30 |
+
template<class State>
|
| 31 |
+
bool start-join-sender(State& state) noexcept; // exposition only
|
| 32 |
+
};
|
| 33 |
+
}
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
For purposes of determining the existence of a data race, `get_token`,
|
| 37 |
+
`close`, `join`, *`try-associate`*, *`disassociate`*, and
|
| 38 |
+
*`start-join-sender`* behave as atomic operations [[intro.multithread]].
|
| 39 |
+
These operations on a single object of type `simple_counting_scope`
|
| 40 |
+
appear to occur in a single total order.
|
| 41 |
+
|
| 42 |
+
##### Constructor and Destructor <a id="exec.simple.counting.ctor">[[exec.simple.counting.ctor]]</a>
|
| 43 |
+
|
| 44 |
+
``` cpp
|
| 45 |
+
simple_counting_scope() noexcept;
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
*Ensures:* *count* is `0` and *state* is *unused*.
|
| 49 |
+
|
| 50 |
+
``` cpp
|
| 51 |
+
~simple_counting_scope();
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
*Effects:* If *state* is not one of *joined*, *unused*, or
|
| 55 |
+
*unused-and-closed*, invokes `terminate` [[except.terminate]].
|
| 56 |
+
Otherwise, has no effects.
|
| 57 |
+
|
| 58 |
+
##### Members <a id="exec.simple.counting.mem">[[exec.simple.counting.mem]]</a>
|
| 59 |
+
|
| 60 |
+
``` cpp
|
| 61 |
+
token get_token() noexcept;
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
*Returns:* An object `t` of type `simple_counting_scope::token` such
|
| 65 |
+
that `t.`*`scope`*` == this` is `true`.
|
| 66 |
+
|
| 67 |
+
``` cpp
|
| 68 |
+
void close() noexcept;
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
*Effects:* If *state* is
|
| 72 |
+
|
| 73 |
+
- *unused*, then changes *state* to *unused-and-closed*;
|
| 74 |
+
- *open*, then changes *state* to *closed*;
|
| 75 |
+
- *open-and-joining*, then changes *state* to *closed-and-joining*;
|
| 76 |
+
- otherwise, no effects.
|
| 77 |
+
|
| 78 |
+
*Ensures:* Any subsequent call to *`try-associate`*`()` on `*this`
|
| 79 |
+
returns `false`.
|
| 80 |
+
|
| 81 |
+
``` cpp
|
| 82 |
+
sender auto join() noexcept;
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
*Returns:* *`make-sender`*`(`*`scope-join-t`*`(), this)`.
|
| 86 |
+
|
| 87 |
+
``` cpp
|
| 88 |
+
bool try-associate() noexcept;
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
*Effects:* If *count* is equal to `max_associations`, then no effects.
|
| 92 |
+
Otherwise, if *state* is
|
| 93 |
+
|
| 94 |
+
- *unused*, then increments *count* and changes *state* to *open*;
|
| 95 |
+
- *open* or *open-and-joining*, then increments *count*;
|
| 96 |
+
- otherwise, no effects.
|
| 97 |
+
|
| 98 |
+
*Returns:* `true` if *count* was incremented, `false` otherwise.
|
| 99 |
+
|
| 100 |
+
``` cpp
|
| 101 |
+
void disassociate() noexcept;
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
*Preconditions:* *count* is greater than zero.
|
| 105 |
+
|
| 106 |
+
*Effects:* Decrements *count*. If *count* is zero after decrementing and
|
| 107 |
+
*state* is *open-and-joining* or *closed-and-joining*, changes *state*
|
| 108 |
+
to *joined* and calls *`complete`*`()` on all objects registered with
|
| 109 |
+
`*this`.
|
| 110 |
+
|
| 111 |
+
[*Note 1*: Calling *`complete`*`()` on any registered object can cause
|
| 112 |
+
`*this` to be destroyed. — *end note*]
|
| 113 |
+
|
| 114 |
+
``` cpp
|
| 115 |
+
template<class State>
|
| 116 |
+
bool start-join-sender(State& st) noexcept;
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
*Effects:* If *state* is
|
| 120 |
+
|
| 121 |
+
- *unused*, *unused-and-closed*, or *joined*, then changes *state* to
|
| 122 |
+
*joined* and returns `true`;
|
| 123 |
+
- *open* or *open-and-joining*, then changes *state* to
|
| 124 |
+
*open-and-joining*, registers `st` with `*this` and returns `false`;
|
| 125 |
+
- *closed* or *closed-and-joining*, then changes *state* to
|
| 126 |
+
*closed-and-joining*, registers `st` with `*this` and returns `false`.
|
| 127 |
+
|
| 128 |
+
##### Token <a id="exec.simple.counting.token">[[exec.simple.counting.token]]</a>
|
| 129 |
+
|
| 130 |
+
``` cpp
|
| 131 |
+
namespace std::execution {
|
| 132 |
+
struct simple_counting_scope::token {
|
| 133 |
+
template<sender Sender>
|
| 134 |
+
Sender&& wrap(Sender&& snd) const noexcept;
|
| 135 |
+
bool try_associate() const noexcept;
|
| 136 |
+
void disassociate() const noexcept;
|
| 137 |
+
|
| 138 |
+
private:
|
| 139 |
+
simple_counting_scope* scope; // exposition only
|
| 140 |
+
};
|
| 141 |
+
}
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
``` cpp
|
| 145 |
+
template<sender Sender>
|
| 146 |
+
Sender&& wrap(Sender&& snd) const noexcept;
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
*Returns:* `std::forward<Sender>(snd)`.
|
| 150 |
+
|
| 151 |
+
``` cpp
|
| 152 |
+
bool try_associate() const noexcept;
|
| 153 |
+
```
|
| 154 |
+
|
| 155 |
+
*Effects:* Equivalent to: `return `*`scope`*`->`*`try-associate`*`();`
|
| 156 |
+
|
| 157 |
+
``` cpp
|
| 158 |
+
void disassociate() const noexcept;
|
| 159 |
+
```
|
| 160 |
+
|
| 161 |
+
*Effects:* Equivalent to *`scope`*`->`*`disassociate`*`()`.
|
| 162 |
+
|