参考
概念
发送器工厂
-
constexpr __read::__read_env_t stdexec::read_env = {}
-
struct just_from_t : public exec::_just_from<just_from_t>
just_from(fn)
创建一个发送器,它通过将 “sink” 函数传递给fn
来内联完成。 使用参数调用 sink 函数会将参数作为值发送给接收器。传递给
just_from
的函数必须返回stdexec::completion_signatures<>
的特例化实例,该实例描述了可能调用 sink 函数的方式。 sink 函数返回stdexec::completion_signatures<>
的此类特例化,该特例化对应于传递给它的参数,但是如果你的函数以几种不同的方式使用 sink 函数,则必须显式指定返回类型。- 示例
// The following sender is equivalent to just(42, 3.14): auto sndr = exec::just_from([](auto sink) { return sink(42, 3.14); });
- 示例
// A just_from sender can have multiple completion signatures: auto sndr = exec::just_from( [](auto sink) { if (some-condition) { sink(42); } else { sink(3.14); } return stdexec::completion_signatures<stdexec::set_value_t(int), stdexec::set_value_t(double)>{}; });
- 参数 fn:
启动发送器时要调用的可调用对象。
- Post:
传递给
fn
的 sink 函数必须恰好被调用一次。
-
constexpr just_from_t exec::just_from = {}
发送器适配器
-
constexpr then_t stdexec::then
then 发送器适配器,它使用发送器的结果调用一个函数,使结果可用于下一个接收器。
发送器消费者
-
constexpr sync_wait_t stdexec::sync_wait = {}