namespace std::execution {
template<class CPO>
struct get_completion_scheduler_t { unspecified };
template<class CPO>
constexpr get_completion_scheduler_t<CPO> get_completion_scheduler{};
}
概要
get_completion_scheduler<completion-tag>
は、Senderの属性から指定完了タグに関連付けられた完了Schedulerを取得するクエリオブジェクトである。
完了タグcompletion-tag
には、set_value_t
, set_error_t
, set_stopped_t
のいずれかを指定する。
コア定数式forwarding_query(get_completion_scheduler<completion-tag>)
はtrue
値を返す。
完了Scheduler
完了Scheduler(completion scheduler)は、非同期操作の完了操作を実行するための実行リソース(例:CPUスレッド)と関連付けられたSchedulerである。
非同期操作の完了操作は、下記いずれかの完了関数呼び出しが該当する。
- 値完了関数
execution::set_value
- エラー完了関数
execution::set_error
- 停止完了関数
execution::set_stopped
効果
呼び出し式get_completion_scheduler<completion-tag>(q)
は下記と等価であり、式が適格ならばscheduler
を満たす型の値となる。
- 引数
q
がconst修飾されたcq
を用いて、式cq.query(get_completion_scheduler<completion-tag>)
が適格であればその値。 - そうでなければ、呼び出し式は不適格となる。
例外
投げない
カスタマイゼーションポイント
const修飾クエリ可能オブジェクトcq
に対して式cq.query(get_completion_scheduler<completion-tag>)
が呼び出される。
このとき、noexcept(cq.query(get_completion_scheduler<completion-tag>)) == true
であること。
例
#include <execution>
namespace ex = std::execution;
int main()
{
ex::run_loop loop;
ex::scheduler auto loop_sch = loop.get_scheduler();
// schedule(loop_sch)の完了Schedulerはloop_schに等しい
ex::sender auto snd0 = ex::schedule(loop_sch);
auto sch0 = ex::get_completion_scheduler<ex::set_value_t>(ex::get_env(snd0));
assert(sch0 == loop_sch);
// 完了Schedulerは接続されたSenderへと引き継がれる
ex::sender auto snd1 = snd0 | ex::then([]{ return 42; });
auto sch1 = ex::get_completion_scheduler<ex::set_value_t>(ex::get_env(snd1));
assert(sch1 == loop_sch);
#if 0
// just Senderは完了Schedulerを持たない
ex::sender auto snd2 = ex::just(42);
auto sch2 = ex::get_completion_scheduler<ex::set_value_t>(ex::get_env(snd2));
#endif
}
出力
バージョン
言語
- C++26
処理系
- Clang: ??
- GCC: ??
- ICC: ??
- Visual C++: ??
関連項目
execution::scheduler
execution::schedule
execution::set_value
execution::set_error
execution::set_stopped