Public Member Functions | List of all members
rapidsmpf::streaming::Channel Class Reference

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< Messagereceive ()
 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...
 

Detailed Description

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.

Member Function Documentation

◆ drain()

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.

Parameters
executorThe thread pool used to process remaining messages.
Returns
A coroutine representing the completion of the shutdown drain.

◆ empty()

bool rapidsmpf::streaming::Channel::empty ( ) const
noexcept

Check whether the channel is empty.

Returns
True if there are no messages in the buffer.

◆ receive()

coro::task<Message> rapidsmpf::streaming::Channel::receive ( )

Asynchronously receive a message from the channel.

Suspends if the channel is empty.

Returns
A coroutine that evaluates to the message, which will be empty if the channel is shut down.

◆ send()

coro::task<bool> rapidsmpf::streaming::Channel::send ( Message  msg)

Asynchronously send a message into the channel.

Suspends if the channel is full.

Parameters
msgThe msg to send.
Returns
A coroutine that evaluates to true if the msg was successfully sent or false if the channel was shut down.

◆ shutdown()

Node rapidsmpf::streaming::Channel::shutdown ( )

Immediately shuts down the channel.

Any pending or future send/receive operations will complete with failure.

Returns
A coroutine representing the completion of the shutdown.

The documentation for this class was generated from the following file: