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

履歴 編集

class
<execution>

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

namespace std::execution {
  class inline_scheduler {
    class inline-sender; // exposition only
    template <receiver R>
    class inline-state;  // exposition only

  public:
    using scheduler_concept = scheduler_t;

    constexpr inline-sender schedule() noexcept { return {}; }
    constexpr bool operator==(const inline_scheduler&) const noexcept = default;
  };
}

概要

inline_schedulerは、インラインでタスクを実行するSchedulerである。

schedule操作により得られるSenderReceiver接続(connect)したOperationStateは、開始(start)したスレッド上で即座に値完了する。

inline_scheduler型の全オブジェクトは等しい。

クラス仕様

説明専用のクラスinline-sendersenderを満たす。completion_signatures_of_t<inline-sender>は、completion_signatures<set_value_t()>となる。

説明用のsndrinline-sender型の式とする。CScompletion_signatures<set_value_t()>としたとき、rcvrreceiver_of<decltype((rcvr)), CS>trueとなる式とする。

説明用のoinline-state<Rcvr>型の非const左辺値とし、REC(o)oを返す接続(connect)呼び出しへ渡した式rcvrで初期化されたRcvr型の非const左辺値参照とする。

  • REC(o)が参照するオブジェクトは、oが参照するオブジェクトの生存期間(lifetime)で有効である。
  • start(o)は、set_value(std::move(REC(o)))と等価。

メンバ関数

名前 説明 対応バージョン
(constructor) コンストラクタ C++26
(destructor) デストラクタ C++26
schedule スケジュールSenderを返す C++26

メンバ型

名前 説明 対応バージョン
scheduler_concept scheduler_t C++26

#include <execution>
#include <print>
namespace ex = std::execution;

int main()
{
  ex::scheduler auto sch = ex::inline_scheduler{};

  std::this_thread::sync_wait(
    ex::schedule(sch)
    | ex::then([]{ std::println("task"); })
  );
}

出力

task

バージョン

言語

  • C++26

処理系

関連項目

参照