Skip to content

Commit 23cf8aa

Browse files
committed
execution: operation_state (#1384)
1 parent 2b4f515 commit 23cf8aa

5 files changed

Lines changed: 97 additions & 4 deletions

File tree

reference/execution/execution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace std::execution {
7272
7373
| 名前 | 説明 | 対応バージョン |
7474
|------|------|----------------|
75-
| [`execution::operation_state`](execution/operation_state.md.nolink) | Operation State (concept) | C++26 |
75+
| [`execution::operation_state`](execution/operation_state.md) | Operation State型 (concept) | C++26 |
7676
| [`execution::start`](execution/start.md.nolink) | 非同期操作の開始 (customization point object) | C++26 |
7777
7878
### Sender
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# operation_state
2+
* execution[meta header]
3+
* concept[meta id-type]
4+
* std::execution[meta namespace]
5+
* cpp26[meta cpp]
6+
7+
```cpp
8+
namespace std::execution {
9+
template<class O>
10+
concept operation_state =
11+
derived_from<typename O::operation_state_concept, operation_state_t> &&
12+
is_object_v<O> &&
13+
requires (O& o) {
14+
{ start(o) } noexcept;
15+
};
16+
17+
struct operation_state_t {}; // タグ型
18+
}
19+
```
20+
* derived_from[link /reference/concepts/derived_from.md]
21+
* is_object_v[link /reference/type_traits/is_object.md]
22+
* start[link start.md.nolink]
23+
24+
## 概要
25+
`operation_state`は、型`O`がOperation State型の要件を満たすことを表すコンセプトである。
26+
27+
下記をみたすクラス型はOperation Stateとみなせる。
28+
29+
- `operation_state_t`をメンバ型`O::operation_state_concept`として定義するクラス型
30+
- `O`型の左辺値`o`に対して`execution::start(o)`が有効な式かつ例外送出されないこと
31+
32+
非同期操作の生存期間中に`operation_state`オブジェクトが破棄されると、未定義の動作を引き起こす。
33+
34+
35+
## 例
36+
```cpp
37+
#include <print>
38+
#include <execution>
39+
namespace ex = std::execution;
40+
41+
struct ValueReceiver {
42+
using receiver_concept = ex::receiver_t;
43+
44+
void set_value(int v) noexcept
45+
{
46+
std::println("{}", v);
47+
}
48+
};
49+
50+
int main()
51+
{
52+
// 値42を送信するSender
53+
ex::sender auto sndr = ex::just(42);
54+
// int値を受信して表示するReceiver
55+
ValueReceiver rcvr;
56+
57+
// SenderとReceiverを接続
58+
ex::operation_state auto op = ex::connect(sndr, rcvr);
59+
// Operation Stateを開始
60+
ex::start(op);
61+
}
62+
```
63+
* ex::operation_state[color ff0000]
64+
* ex::sender[link sender.md]
65+
* ex::just[link just.md.nolink]
66+
* ex::connect[link connect.md.nolink]
67+
* ex::start[link start.md.nolink]
68+
69+
### 出力
70+
```
71+
42
72+
```
73+
74+
75+
## バージョン
76+
### 言語
77+
- C++26
78+
79+
### 処理系
80+
- [Clang](/implementation.md#clang): ??
81+
- [GCC](/implementation.md#gcc): ??
82+
- [ICC](/implementation.md#icc): ??
83+
- [Visual C++](/implementation.md#visual_cpp): ??
84+
85+
86+
## 関連項目
87+
- [`execution::connect`](connect.md.nolink)
88+
89+
90+
## 参照
91+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)

reference/execution/execution/sender_in.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace std::execution {
3131
3232
また、ある完了操作の完了シグネチャが[`completion_signatures_of_t`](completion_signatures_of_t.md)`<Sndr, Env>`で取得される[`completion_signatures`](completion_signatures.md)リストに含まれるとき、`Sndr`と`Env`における許容可能完了(permissible completion)となる。
3333
34-
`sndr`と`rcvr`の接続後に[Operation State](operation_state.md.nolink)を開始することで評価されうる完了操作が、全て許容可能完了(permissible completion)である場合、`Sndr`と`Env`は`sender_in<Sndr, Env>`のモデルとなる。
34+
`sndr`と`rcvr`の接続後に[Operation State](operation_state.md)を開始することで評価されうる完了操作が、全て許容可能完了(permissible completion)である場合、`Sndr`と`Env`は`sender_in<Sndr, Env>`のモデルとなる。
3535
3636
3737
## 例

reference/execution/execution/sender_to.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,16 @@ int main()
4949
// int値を受信して表示するReceiver
5050
ValueReceiver rcvr;
5151
52-
// SenderとReceiver接続後にOperation Stateを開始
52+
// SenderとReceiverを接続
5353
ex::operation_state auto op = ex::connect(sndr, rcvr);
54+
// Operation Stateを開始
5455
ex::start(op);
5556
}
5657
```
5758
* ex::sender_to[color ff0000]
5859
* ex::sender[link sender.md]
5960
* ex::just[link just.md.nolink]
60-
* ex::operation_state[link operation_state.md.nolink]
61+
* ex::operation_state[link operation_state.md]
6162
* ex::connect[link connect.md.nolink]
6263
* ex::start[link start.md.nolink]
6364

working_style.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ C++11以降対応については対応バージョンを明記します。バー
6767
| apply, application | 適用 |
6868
| arithmetic type | 算術型 |
6969
| associative container(s) | 連想コンテナ |
70+
| asynchronous operation | 非同期操作 |
7071
| base class | 基底クラス |
7172
| bidirectional iterator | 双方向イテレータ |
7273
| bucket | バケット |

0 commit comments

Comments
 (0)