A coroutine-based channel for sending and receiving messages asynchronously. More...
#include <channel.hpp>
Public Member Functions | |
| coro::task< bool > | send (Message msg) |
| Asynchronously send a message into the channel. More... | |
| coro::task< Message > | receive () |
| Asynchronously receive a message from the channel. More... | |
| Node | drain (std::unique_ptr< coro::thread_pool > &executor) |
| Drains all pending messages from the channel and shuts it down. More... | |
| Node | shutdown () |
| Immediately shuts down the channel. More... | |
| bool | empty () const noexcept |
| Check whether the channel is empty. More... | |
A coroutine-based channel for sending and receiving messages asynchronously.
The constructor is private, use the factory method Context::create_channel() to create a new channel.
Definition at line 37 of file channel.hpp.
| Node rapidsmpf::streaming::Channel::drain | ( | std::unique_ptr< coro::thread_pool > & | executor | ) |
Drains all pending messages from the channel and shuts it down.
This is intended to ensure all remaining messages are processed.
| executor | The thread pool used to process remaining messages. |
|
noexcept |
Check whether the channel is empty.
| coro::task<Message> rapidsmpf::streaming::Channel::receive | ( | ) |
Asynchronously receive a message from the channel.
Suspends if the channel is empty.
| coro::task<bool> rapidsmpf::streaming::Channel::send | ( | Message | msg | ) |
Asynchronously send a message into the channel.
Suspends if the channel is full.
| msg | The msg to send. |
| Node rapidsmpf::streaming::Channel::shutdown | ( | ) |
Immediately shuts down the channel.
Any pending or future send/receive operations will complete with failure.