Skip to content

Commit 2a210a5

Browse files
committed
execution: sync_wait(_with_variant) (#1384)
1 parent e6b7e2c commit 2a210a5

File tree

9 files changed

+506
-8
lines changed

9 files changed

+506
-8
lines changed

reference/execution/execution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ namespace std::execution {
133133
134134
| 名前 | 説明 | 対応バージョン |
135135
|------|------|----------------|
136-
| [`this_thread::sync_wait`](this_thread/sync_wait.md.nolink) | 現在のスレッド上でSender完了を待機 (customization point object) | C++26 |
137-
| [`this_thread::sync_wait_with_variant`](this_thread/sync_wait_with_variant.md.nolink) | 現在のスレッド上でSender完了を待機 (customization point object) | C++26 |
136+
| [`this_thread::sync_wait`](this_thread/sync_wait.md) | 現在のスレッド上でSender完了を待機 (customization point object) | C++26 |
137+
| [`this_thread::sync_wait_with_variant`](this_thread/sync_wait_with_variant.md) | 現在のスレッド上でSender完了を待機 (customization point object) | C++26 |
138138
139139
Senderコンシューマは名前空間 `std::this_thread` で定義される。
140140

reference/execution/execution/completion-domain.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ constexpr auto completion-domain(const Sndr& sndr) noexcept;
3232
3333
3434
## 関連項目
35-
- [`get-domain-early`](get-domain-early.md.nolink)
35+
- [`get-domain-early`](get-domain-early.md)
3636
- [`get-domain-late`](get-domain-late.md)
3737
3838
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# get-domain-early
2+
* execution[meta header]
3+
* function template[meta id-type]
4+
* std::execution[meta namespace]
5+
* cpp26[meta cpp]
6+
7+
```cpp
8+
template<class Sndr>
9+
constexpr auto get-domain-early(const Sndr& sndr) noexcept;
10+
```
11+
12+
## 概要
13+
[Sender](sender.md)アルゴリズム構築時のカスタマイゼーションポイントとして、[実行ドメイン](default_domain.md)を取得する説明専用の関数テンプレート。
14+
15+
下記の優先順で実行ドメインを検索し、最初に妥当となる型を採用する。
16+
17+
- Senderの[属性](../queryable.md)の実行ドメイン
18+
- Senderの[完了Scheduler](get_completion_scheduler.md)の実行ドメイン
19+
- [デフォルト実行ドメイン](default_domain.md)
20+
21+
22+
## 効果
23+
説明用の型`Domain`を下記リストのうち最初に妥当となる式の型と定義したとき、`return Doamin();`と等価。
24+
25+
- [`get_domain`](get_domain.md)`(`[`get_env`](get_env.md)`(sndr))`
26+
- [`completion-domain`](completion-domain.md)`(sndr)`
27+
- [`default_domain()`](default_domain.md)
28+
29+
30+
## 例外
31+
投げない
32+
33+
34+
## バージョン
35+
### 言語
36+
- C++26
37+
38+
39+
## 関連項目
40+
- [`this_thread::sync_wait`](../this_thread/sync_wait.md)
41+
- [`this_thread::sync_wait_with_variant`](../this_thread/sync_wait_with_variant.md)
42+
43+
44+
## 参照
45+
- [P2999R3 Sender Algorithm Customization](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2999r3.html)
46+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)

reference/execution/execution/get-domain-late.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ constexpr auto get-domain-late(const Sndr& sndr, const Env& env) noexcept;
1515
下記の優先順で実行ドメインを検索し、最初に妥当となる型を採用する。
1616
(Senderアルゴリズム[`continue_on`](continue_on.md.nolink)のみ引数に指定した[Scheduler](scheduler.md)から取得。)
1717
18-
- Senderの[属性](../queryable.md)
19-
- Senderの[完了Scheduler](get_completion_scheduler.md)
20-
- Receiverの[環境](../queryable.md)
21-
- Receiver環境の[Scheduler](scheduler.md)
22-
- [`default_domain`](default_domain.md)
18+
- Senderの[属性](../queryable.md)の実行ドメイン
19+
- Senderの[完了Scheduler](get_completion_scheduler.md)の実行ドメイン
20+
- Receiverの[環境](../queryable.md)の実行ドメイン
21+
- Receiver環境の[Scheduler](scheduler.md)の実行ドメイン
22+
- [デフォルト実行ドメイン](default_domain.md)
2323
2424
2525
## 効果

reference/execution/this_thread.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# this_thread
2+
* execution[meta header]
3+
* std[meta namespace]
4+
* namespace[meta id-type]
5+
* cpp26[meta cpp]
6+
7+
ヘッダ [`<execution>`](../execution.md) の名前空間 `std::this_thread` では、実行制御ライブラリの一部エンティティを定義する。
8+
9+
```cpp
10+
namespace std::this_thread {
11+
12+
}
13+
```
14+
15+
実行制御ライブラリ全体は名前空間 [`std::execution`](../execution/execution.md) ページを参照のこと。
16+
17+
18+
## バージョン
19+
### 言語
20+
- C++26
21+
22+
## 参照
23+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# sync-wait-env
2+
* execution[meta header]
3+
* class template[meta id-type]
4+
* std::this_thread[meta namespace]
5+
* cpp26[meta cpp]
6+
7+
```cpp
8+
namespace std::this_thread {
9+
struct sync-wait-env {
10+
execution::run_loop* loop; // exposition only
11+
12+
auto query(execution::get_scheduler_t) const noexcept {
13+
return loop->get_scheduler();
14+
}
15+
16+
auto query(execution::get_delegation_scheduler_t) const noexcept {
17+
return loop->get_scheduler();
18+
}
19+
};
20+
}
21+
```
22+
* execution::run_loop[link ../execution/run_loop.md]
23+
* execution::get_scheduler_t[link ../execution/get_scheduler.md]
24+
* execution::get_delegation_scheduler_t[link ../execution/get_delegation_scheduler.md]
25+
* get_scheduler()[link ../execution/run_loop/get_scheduler.md]
26+
27+
## 概要
28+
`sync-wait-env`は、実行制御ライブラリの仕様定義で用いられる説明専用のクラステンプレートである。
29+
30+
Senderコンシューマ[`sync_wait`](sync_wait.md)、[`sync_wait_with_variant`](sync_wait_with_variant.md)動作において[Receiver](../execution/receiver.md)の[環境](../queryable.md)として利用される。
31+
32+
33+
## バージョン
34+
### 言語
35+
- C++26
36+
37+
38+
## 関連項目
39+
- [`this_thread::sync_wait`](sync_wait.md)
40+
- [`this_thread::sync_wait_with_variant`](sync_wait_with_variant.md)
41+
- [`execution::run_loop`](../execution/run_loop.md)
42+
43+
44+
## 参照
45+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# sync-wait-receiver
2+
* execution[meta header]
3+
* class template[meta id-type]
4+
* std::this_thread[meta namespace]
5+
* cpp26[meta cpp]
6+
7+
```cpp
8+
namespace std::this_thread {
9+
template<class Sndr>
10+
struct sync-wait-receiver { // exposition only
11+
using receiver_concept = execution::receiver_t;
12+
sync-wait-state<Sndr>* state; // exposition only
13+
14+
template<class... Args>
15+
void set_value(Args&&... args) && noexcept;
16+
17+
template<class Error>
18+
void set_error(Error&& err) && noexcept;
19+
20+
void set_stopped() && noexcept;
21+
22+
sync-wait-env get_env() const noexcept { return {&state->loop}; }
23+
};
24+
25+
template<class Sndr>
26+
struct sync-wait-state { // exposition only
27+
execution::run_loop loop; // exposition only
28+
exception_ptr error; // exposition only
29+
sync-wait-result-type<Sndr> result; // exposition only
30+
};
31+
}
32+
```
33+
* execution::receiver_t[link ../execution/receiver.md]
34+
* execution::run_loop[link ../execution/run_loop.md]
35+
* exception_ptr[link /reference/exception/exception_ptr.md]
36+
* sync-wait-result-type[link sync_wait.md]
37+
38+
## 概要
39+
`sync-wait-receiver`および`sync-wait-state`は、実行制御ライブラリの仕様定義で用いられる説明専用のクラステンプレートである。
40+
41+
Senderコンシューマ[`sync_wait`](sync_wait.md)動作において[Sender](../execution/sender.md)と[接続(connect)](../execution/connect.md)する[Receiver](../execution/receiver.md)、同Receiverの内部状態として利用される。
42+
43+
44+
### メンバ関数 `set_value`
45+
```cpp
46+
template<class... Args>
47+
void set_value(Args&&... args) && noexcept;
48+
```
49+
50+
効果 : 下記と等価
51+
52+
```cpp
53+
try {
54+
state->result.emplace(std::forward<Args>(args)...);
55+
} catch (...) {
56+
state->error = current_exception();
57+
}
58+
state->loop.finish();
59+
```
60+
* emplace[link /reference/optional/optional/emplace.md]
61+
* current_exception()[link /reference/exception/current_exception.md]
62+
* finish()[link ../execution/run_loop/finish.md]
63+
64+
65+
### メンバ関数 `set_error`
66+
```cpp
67+
template<class Error>
68+
void set_error(Error&& err) && noexcept
69+
```
70+
71+
説明用の式`err`に対して`decltype((err))`を型`Err`としたとき、式`AS-EXCEPT-PTR(err)`を下記の通り定義する。
72+
73+
- [`decay_t`](/reference/type_traits/decay.md)`<Err>`が[`exception_ptr`](/reference/exception/exception_ptr.md)型と等しければ、`err`となる。このとき、事前条件として`!err == false`を満たすこと。
74+
- そうではなく、[`decay_t`](/reference/type_traits/decay.md)`<Err>`が[`error_code`](/reference/system_error/error_code.md)型と等しければ、[`make_exception_ptr`](/reference/exception/make_exception_ptr.md)`(`[`system_error`](/reference/system_error/system_error.md)`(err))`となる。
75+
- そうでなければ、[`make_exception_ptr`](/reference/exception/make_exception_ptr.md)`(err)`となる。
76+
77+
効果 : 下記と等価
78+
79+
```cpp
80+
state->error = AS-EXCEPT-PTR(std::forward<Error>(err));
81+
state->loop.finish();
82+
```
83+
* finish()[link ../execution/run_loop/finish.md]
84+
85+
86+
### メンバ関数 `set_stopped`
87+
```cpp
88+
void set_stopped() && noexcept;
89+
```
90+
91+
効果 : `state->loop.`[`finish()`](../execution/run_loop/finish.md)と等価。
92+
93+
94+
## バージョン
95+
### 言語
96+
- C++26
97+
98+
99+
## 関連項目
100+
- [`this_thread::sync_wait`](sync_wait.md)
101+
- [`execution::run_loop`](../execution/run_loop.md)
102+
103+
104+
## 参照
105+
- [P2300R10 `std::execution`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html)

0 commit comments

Comments
 (0)