Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

execution::connect

A customisation point that connects a sender to a receiver.

constexpr unspecified connect = unspecified;

The name execution::connect denotes a customisation point object. For some subexpressions s and r, let S be a type such that decltype((s)) is S and let R be a type such that decltype((r)) is R. The expression execution::connect(s, r) is expression-equivalent to:

template <class S, class R>
 struct as_operation
 {
   remove_cvref_t<S> e_;
   remove_cvref_t<R> r_;
   void start() noexcept try {
     execution::execute(std::move(e_),
         as_invocable<remove_cvref_t<R>, S>{r_});
   } catch(...) {
     execution::set_error(std::move(r_), current_exception());
   }
 };

and as_invocable is a class template equivalent to the following:

template<class R>
 struct as_invocable
 {
   R* r_;
   explicit as_invocable(R& r) noexcept
     : r_(std::addressof(r)) {}
   as_invocable(as_invocable && other) noexcept
     : r_(std::exchange(other.r_, nullptr)) {}
   ~as_invocable() {
     if(r_)
       execution::set_done(std::move(*r_));
   }
   void operator()() & noexcept try {
     execution::set_value(std::move(*r_));
     r_ = nullptr;
   } catch(...) {
     execution::set_error(std::move(*r_), current_exception());
     r_ = nullptr;
   }
 };
Requirements

Header: boost/asio/execution/connect.hpp

Convenience header: boost/asio/execution.hpp


PrevUpHomeNext