Boost C++ Libraries/Boost.Asio

Boost.Asio 색인 - execution::connect

까마귀75 2021. 1. 24. 13:16
728x90
반응형

execution::connect

송신기와 수신기를 연결하는 사용자 지정 지점이다.

constexpr unspecified connect = unspecified;

execution::connect 이름은 사용자 지정 지점 개체를 나타낸다. 일부 하위 표현식 sr의 경우, decltype((s))S와 같은 S 유형과 dectype((r))R과 같은 R 유형이 되도록 한다. 표현식 execution::connect(s, r)는 다음 표현식과 동일하다:

  •  s.connect(r) 표현식이 유효하고, 해당 유형이 operation_state를 만족하고 S가 송신기를 만족하는 경우.
  • 그렇지 않으면, connect(s, r) 표현식이 유효하고, 해당 유형이 operation_state를 만족하고, S가 송신기를 만족하는 경우로, void connect(); 선언을 포함하고 execution::connect의 선언이 포함되지 않은 컨텍스트에서 오버로드 작업이 수행된다.
  • 그렇지 않으면, as_operation{s, r}, r이 일부 유형 F에 대해 as_receiver<F, S>의 인스턴스가 아니고 receiver_of<R> && executor_of<remove_cvref_t<S>, as_invocable<remove_cvref_t<R>, S>>true인 경우, 여기서 as_operation은 다음과 동일한 구현-정의된 클래스이다:

    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());
       }
     };

    그리고 as_invocable은 다음과 동일한 클래스 템플릿이다:

    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;
       }
     };
  • 그렇지 않으면 execution_connect(s, r) 형식이 잘못된 것이다.

요구 사항

일반 헤더: boost/asio/execution/connect.hpp
편의 헤더: boost/asio/execution.hpp

Boost.Asio 홈

728x90
반응형