Skip to content

Commit 3c66609

Browse files
committed
stop_token: inplace_stop_token全メンバ (#1384)
- stop_token/op_equal P2300R10追従して定義変更 - stop_token/swap_free 備考を追記(定義削除も影響なし)
1 parent 3d75bda commit 3c66609

File tree

13 files changed

+321
-16
lines changed

13 files changed

+321
-16
lines changed

reference/stop_token.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
`<stop_token>`ヘッダは、マルチスレッド処理や非同期処理おける停止要求の状態 `停止状態` を扱うクラスを定義する。
66

77
- [`stop_token`](stop_token/stop_token.md), [`stop_source`](stop_token/stop_source.md), [`stop_callback`](stop_token/stop_callback.md)は停止状態を共有所有する。最後に破棄されたオブジェクトが停止状態を自動的に解放する。
8-
- [`inplace_stop_source`](stop_token/inplace_stop_source.md)は停止状態をメンバとして直接所有する。[`inplace_stop_token`](stop_token/inplace_stop_token.md.nolink)[`inplace_stop_callback`](stop_token/inplace_stop_callback.md.nolink)は停止状態の所有には関与しない。
8+
- [`inplace_stop_source`](stop_token/inplace_stop_source.md)は停止状態をメンバとして直接所有する。[`inplace_stop_token`](stop_token/inplace_stop_token.md)[`inplace_stop_callback`](stop_token/inplace_stop_callback.md.nolink)は停止状態の所有には関与しない。
99

1010

1111
## コンセプト
@@ -22,7 +22,7 @@
2222
| [`stop_callback`](stop_token/stop_callback.md)| [`stop_source`](stop_token/stop_source.md)停止要求に応じて呼び出されるコールバック (class template) | C++20 |
2323
| [`nostopstate`](stop_token/nostopstate.md) | 停止状態を扱わない[`stop_source`](stop_token/stop_source.md)構築用タグ (class) | C++20 |
2424
| [`never_stop_token`](stop_token/never_stop_token.md) | 停止不可能な停止トークン (class) | C++26 |
25-
| [`inplace_stop_token`](stop_token/inplace_stop_token.md.nolink) | [`inplace_stop_source`](stop_token/inplace_stop_source.md)の停止トークン (class) | C++26 |
25+
| [`inplace_stop_token`](stop_token/inplace_stop_token.md) | [`inplace_stop_source`](stop_token/inplace_stop_source.md)の停止トークン (class) | C++26 |
2626
| [`inplace_stop_source`](stop_token/inplace_stop_source.md) | 停止状態を直接所有する停止要求インタフェース (class) | C++26 |
2727
| [`inplace_stop_callback`](stop_token/inplace_stop_callback.md.nolink) | [`inplace_stop_source`](stop_token/inplace_stop_source.md)停止要求に応じて呼び出されるコールバック (class template) | C++26 |
2828
| [`stop_callback_for_t`](stop_token/stop_callback_for_t.md) | 対応するコールバック型を取得 (alias template) | C++26 |

reference/stop_token/inplace_stop_source.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace std {
2323
| [`(constructor)`](inplace_stop_source/op_constructor.md) | コンストラクタ | C++26 |
2424
| `(destructor)` | デストラクタ | C++26 |
2525
| `operator=` | 代入演算子 | C++26 |
26-
| [`get_token`](inplace_stop_source/get_token.md) | 自身の停止状態を参照する[`inplace_stop_token`](inplace_stop_token.md.nolink)を返す | C++26 |
26+
| [`get_token`](inplace_stop_source/get_token.md) | 自身の停止状態を参照する[`inplace_stop_token`](inplace_stop_token.md)を返す | C++26 |
2727
| [`stop_requested`](inplace_stop_source/stop_requested.md) | 停止要求を作成したかどうかを取得する | C++26 |
2828
| [`request_stop`](inplace_stop_source/request_stop.md) | 停止要求を作成する | C++26 |
2929
@@ -57,9 +57,9 @@ int main()
5757
}
5858
```
5959
* std::inplace_stop_source[color ff0000]
60-
* std::inplace_stop_token[link inplace_stop_token.md.nolink]
60+
* std::inplace_stop_token[link inplace_stop_token.md]
6161
* std::inplace_stop_callback[link inplace_stop_callback.md.nolink]
62-
* stop_requested()[link inplace_stop_token/stop_requested.md.nolink]
62+
* stop_requested()[link inplace_stop_token/stop_requested.md]
6363
* request_stop()[link inplace_stop_source/request_stop.md]
6464
* get_token()[link inplace_stop_source/get_token.md]
6565

@@ -80,7 +80,7 @@ int main()
8080

8181

8282
## 関連項目
83-
- [`inplace_stop_token`](inplace_stop_token.md.nolink)
83+
- [`inplace_stop_token`](inplace_stop_token.md)
8484
- [`inplace_stop_callback`](inplace_stop_callback.md.nolink)
8585

8686

reference/stop_token/inplace_stop_source/get_token.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
```cpp
99
constexpr inplace_stop_token get_token() const noexcept;
1010
```
11-
* inplace_stop_token[link ../inplace_stop_token.md.nolink]
11+
* inplace_stop_token[link ../inplace_stop_token.md]
1212

1313
## 概要
14-
自身と停止状態を共有する[`inplace_stop_token`](../inplace_stop_token.md.nolink)を返す。
14+
自身の停止状態を参照する[`inplace_stop_token`](../inplace_stop_token.md)を返す。
1515

1616

1717
## 戻り値
18-
自身が所有する停止状態に関連付けられた[`inplace_stop_token`](../inplace_stop_token.md.nolink)を返す。
18+
自身が所有する停止状態に関連付けられた[`inplace_stop_token`](../inplace_stop_token.md)を返す。
1919

2020

2121
## 例外
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# inplace_stop_token
2+
* stop_token[meta header]
3+
* class[meta id-type]
4+
* std[meta namespace]
5+
* cpp26[meta cpp]
6+
7+
```cpp
8+
namespace std {
9+
class inplace_stop_token;
10+
}
11+
```
12+
13+
## 概要
14+
`inplace_stop_token`クラスは、停止要求が作成されたかどうか、あるいは停止要求が作成されうるかどうかなど、停止状態を問い合わせるためのインターフェースを提供する。
15+
16+
`inplace_stop_token`は[`stoppable_token`](stoppable_token.md)のモデルである。
17+
18+
19+
## メンバ関数
20+
21+
| 名前 | 説明 | 対応バージョン |
22+
|------|------|-------|
23+
| [`(constructor)`](inplace_stop_token/op_constructor.md) | コンストラクタ | C++26 |
24+
| `(destructor)` | デストラクタ | C++26 |
25+
| `operator==` | 等値演算子 | C++26 |
26+
| [`stop_requested`](inplace_stop_token/stop_requested.md)| 停止要求が作成されたかどうかを取得する | C++20 |
27+
| [`stop_possible`](inplace_stop_token/stop_possible.md) | 停止要求が作成されうるかどうかを取得する | C++20 |
28+
| [`swap`](inplace_stop_token/swap.md) | 別の`inplace_stop_token`と交換する | C++20 |
29+
30+
## メンバ型
31+
32+
| 名前 | 説明 | 対応バージョン |
33+
|------|------|-------|
34+
| [`callback_type`](inplace_stop_token/callback_type.md) | 対応するコールバック型 | C++26 |
35+
36+
37+
## 例
38+
```cpp example
39+
#include <cassert>
40+
#include <stop_token>
41+
42+
int main()
43+
{
44+
std::inplace_stop_source ss;
45+
std::inplace_stop_token st = ss.get_token();
46+
assert(st.stop_requested() == false);
47+
48+
ss.request_stop();
49+
50+
assert(st.stop_requested() == true);
51+
}
52+
```
53+
* std::inplace_stop_token[color ff0000]
54+
* std::inplace_stop_source[link inplace_stop_source.md]
55+
* stop_requested()[link inplace_stop_token/stop_requested.md]
56+
* request_stop()[link inplace_stop_source/request_stop.md]
57+
* get_token()[link inplace_stop_source/get_token.md]
58+
59+
### 出力
60+
```
61+
```
62+
63+
64+
## バージョン
65+
### 言語
66+
- C++26
67+
68+
### 処理系
69+
- [Clang](/implementation.md#clang): ??
70+
- [GCC](/implementation.md#gcc): ??
71+
- [ICC](/implementation.md#icc): ??
72+
- [Visual C++](/implementation.md#visual_cpp): ??
73+
74+
75+
## 関連項目
76+
- [`inplace_stop_source`](inplace_stop_source.md)
77+
- [`inplace_stop_callback`](inplace_stop_callback.md.nolink)
78+
79+
80+
## 参照
81+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# callback_type
2+
* stop_token[meta header]
3+
* std[meta namespace]
4+
* inplace_stop_token[meta class]
5+
* type-alias[meta id-type]
6+
* cpp26[meta cpp]
7+
8+
```cpp
9+
template<class CallbackFn>
10+
using callback_type = inplace_stop_callback<CallbackFn>;
11+
```
12+
* inplace_stop_callback[link ../inplace_stop_callback.md.nolink]
13+
14+
## 概要
15+
`inplace_stop_token`に対応するコールバック型。
16+
17+
18+
## バージョン
19+
### 言語
20+
- C++26
21+
22+
### 処理系
23+
- [GCC](/implementation.md#gcc): ??
24+
- [Clang](/implementation.md#clang): ??
25+
- [ICC](/implementation.md#icc): ??
26+
- [Visual C++](/implementation.md#visual_cpp): ??
27+
28+
29+
## 参照
30+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# コンストラクタ
2+
* stop_token[meta header]
3+
* function[meta id-type]
4+
* std[meta namespace]
5+
* inplace_stop_token[meta class]
6+
* cpp26[meta cpp]
7+
8+
```cpp
9+
inplace_stop_token() = default;
10+
```
11+
12+
## 概要
13+
デフォルトコンストラクタ。
14+
15+
16+
## 効果
17+
[`inplace_stop_source`](../inplace_stop_source.md)を参照しない停止トークンとして構築する。
18+
19+
20+
## バージョン
21+
### 言語
22+
- C++26
23+
24+
### 処理系
25+
- [Clang](/implementation.md#clang): ??
26+
- [GCC](/implementation.md#gcc): ??
27+
- [ICC](/implementation.md#icc): ??
28+
- [Visual C++](/implementation.md#visual_cpp): ??
29+
30+
31+
## 参照
32+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# stop_possible
2+
* stop_token[meta header]
3+
* function[meta id-type]
4+
* std[meta namespace]
5+
* inplace_stop_token[meta class]
6+
* cpp26[meta cpp]
7+
8+
```cpp
9+
bool stop_possible() const noexcept;
10+
```
11+
12+
## 概要
13+
停止要求が作成されうるかどうかを返す。
14+
15+
16+
## 効果
17+
自身が[`inplace_stop_source`](../inplace_stop_source.md)を参照する場合に、`true`を返す。
18+
そうでなければ、`false`を返す。
19+
20+
21+
## 例外
22+
投げない
23+
24+
25+
## バージョン
26+
### 言語
27+
- C++26
28+
29+
### 処理系
30+
- [Clang](/implementation.md#clang): ??
31+
- [GCC](/implementation.md#gcc): ??
32+
- [ICC](/implementation.md#icc): ??
33+
- [Visual C++](/implementation.md#visual_cpp): ??
34+
35+
36+
## 参照
37+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# stop_requested
2+
* stop_token[meta header]
3+
* function[meta id-type]
4+
* std[meta namespace]
5+
* inplace_stop_token[meta class]
6+
* cpp26[meta cpp]
7+
8+
```cpp
9+
bool stop_requested() const noexcept;
10+
```
11+
12+
## 概要
13+
停止要求が作成されたかどうかを返す。
14+
15+
16+
## 効果
17+
自身が[`inplace_stop_source`](../inplace_stop_source.md)を参照し、かつ[`stop_requested`](../inplace_stop_source/stop_requested.md)`true`の場合に限って、`true`を返す。
18+
そうでなければ、`false`を返す。
19+
20+
21+
## 例外
22+
投げない
23+
24+
25+
## バージョン
26+
### 言語
27+
- C++26
28+
29+
### 処理系
30+
- [Clang](/implementation.md#clang): ??
31+
- [GCC](/implementation.md#gcc): ??
32+
- [ICC](/implementation.md#icc): ??
33+
- [Visual C++](/implementation.md#visual_cpp): ??
34+
35+
36+
## 参照
37+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# swap
2+
* stop_token[meta header]
3+
* std[meta namespace]
4+
* inplace_stop_token[meta class]
5+
* function[meta id-type]
6+
* cpp26[meta cpp]
7+
8+
```cpp
9+
void swap(inplace_stop_token&) noexcept;
10+
```
11+
12+
## 概要
13+
他の`inplace_stop_token`オブジェクトと値を入れ替える。
14+
15+
## 戻り値
16+
なし
17+
18+
## 例外
19+
投げない
20+
21+
## 例
22+
```cpp example
23+
#include <cassert>
24+
#include <stop_token>
25+
26+
int main()
27+
{
28+
std::inplace_stop_source ss;
29+
std::inplace_stop_token st1 = ss.get_token();
30+
std::inplace_stop_token st2;
31+
32+
assert(st1.stop_possible() == true);
33+
assert(st2.stop_possible() == false);
34+
35+
st1.swap(st2);
36+
37+
assert(st1.stop_possible() == false);
38+
assert(st2.stop_possible() == true);
39+
}
40+
```
41+
* swap[color ff0000]
42+
* std::inplace_stop_token[link ../inplace_stop_token.md]
43+
* std::inplace_stop_source[link ../inplace_stop_source.md]
44+
* stop_possible()[link stop_possible.md]
45+
46+
### 出力
47+
```
48+
```
49+
50+
## バージョン
51+
### 言語
52+
- C++26
53+
54+
### 処理系
55+
- [Clang](/implementation.md#clang): ??
56+
- [GCC](/implementation.md#gcc): ??
57+
- [ICC](/implementation.md#icc): ??
58+
- [Visual C++](/implementation.md#visual_cpp): ??
59+
60+
61+
## 参照
62+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)

reference/stop_token/stop_token.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace std {
1313
## 概要
1414
`stop_token`クラスは、停止要求が作成されたかどうか、あるいは停止要求が作成されうるかどうかなど、停止状態を問い合わせるためのインターフェースを提供する。
1515
16+
`stop_token`は[`stoppable_token`](stoppable_token.md)のモデルである。
17+
1618
[`stop_source`](stop_source.md)クラスの[`get_token()`](stop_source/get_token.md)メンバ関数を呼び出すと、その`stop_source`クラスのオブジェクトと停止状態を共有する`stop_token`クラスのオブジェクトを構築できる。これによって、`stop_source`側から停止要求を作成したときに、この`stop_token`を通じて停止状態を問い合わせられるようになる。
1719
1820
また、`stop_token`クラスは以下のクラスでも利用される:
@@ -38,7 +40,7 @@ namespace std {
3840
3941
| 名前 | 説明 | 対応バージョン |
4042
|------|------|-------|
41-
| [`callback_type`](stop_token/callback_type.md) | 対応するコールバック型 (alias template) | C++26 |
43+
| [`callback_type`](stop_token/callback_type.md) | 対応するコールバック型 | C++26 |
4244
4345
## 非メンバ関数
4446
@@ -80,10 +82,18 @@ int main()
8082
### 言語
8183
- C++20
8284

83-
8485
### 処理系
8586
- [Clang](/implementation.md#clang): ??
8687
- [GCC](/implementation.md#gcc): ??
8788
- [ICC](/implementation.md#icc): ??
8889
- [Visual C++](/implementation.md#visual_cpp): ??
8990

91+
92+
## 関連項目
93+
- [`stop_source`](stop_source.md)
94+
- [`stop_callback`](stop_callback.md)
95+
96+
97+
## 参照
98+
- [P0660R10 Stop token and joining thread](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0660r10.pdf)
99+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)

0 commit comments

Comments
 (0)