|
ORE Studio 0.0.4
|
Single-value async channel for delivering a response frame. More...
#include <response_channel.hpp>

Public Member Functions | |
| response_channel (boost::asio::any_io_executor executor) | |
| response_channel (const response_channel &)=delete | |
| response_channel & | operator= (const response_channel &)=delete |
| response_channel (response_channel &&)=delete | |
| response_channel & | operator= (response_channel &&)=delete |
| void | set_value (messaging::frame response) |
| Set the response value (producer side). | |
| void | set_error (messaging::error_code ec) |
| Set an error (producer side). | |
| boost::asio::awaitable< std::expected< messaging::frame, messaging::error_code > > | get () |
| Wait for and retrieve the response (consumer side). | |
| bool | is_ready () const |
| Check if the channel has already received a value or error. | |
Single-value async channel for delivering a response frame.
Used by the message loop to deliver responses to waiting co-routines. Each channel can hold exactly one response (or error). The consumer calls get() which blocks until set_value() or set_error() is called by the producer (message loop).
Uses a steady_timer as the signaling primitive - a common Boost.Asio pattern for implementing async channels without std::experimental features.
| void set_value | ( | messaging::frame | response | ) |
Set the response value (producer side).
Called by the message loop when a response arrives. Wakes up the waiting get() coroutine.
| response | The response frame to deliver |
| void set_error | ( | messaging::error_code | ec | ) |
Set an error (producer side).
Called by the message loop on timeout or disconnect. Wakes up the waiting get() coroutine with an error.
| ec | The error code to deliver |
| boost::asio::awaitable< std::expected< messaging::frame, messaging::error_code > > get | ( | ) |
Wait for and retrieve the response (consumer side).
Blocks until set_value() or set_error() is called.