最終更新日時(UTC):
が更新

履歴 編集

customization point object
<execution>

std::execution::get_completion_scheduler(C++26)

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である。

同期操作の完了操作は、下記いずれかの完了関数呼び出しが該当する。

効果

呼び出し式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

処理系

関連項目

参照