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

A bounded queue for type-erased Messages. More...

#include <queue.hpp>

Public Member Functions

coro::task< std::optional< Ticket > > acquire ()
 Acquire a ticket to send into the queue. More...
 
coro::task< std::pair< coro::task< void >, Message > > receive ()
 Receive a message from the queue. More...
 
coro::task< void > drain (std::unique_ptr< coro::thread_pool > &executor)
 Drain all messages in the queue and shut down. More...
 
coro::task< void > shutdown ()
 Immediately shut down the queue. More...
 
BoundedQueue::Shutdown raii_shutdown () noexcept
 Obtain an object that will synchronously shutdown the queue when it goes out of scope. More...
 

Detailed Description

A bounded queue for type-erased Messages.

This adds a semaphore-based ticketing system to coro::queue. The producer must acquire a ticket which is sent with the message to the consumer who can decide when to release the ticket having received the message.

Definition at line 31 of file queue.hpp.

Member Function Documentation

◆ acquire()

coro::task<std::optional<Ticket> > rapidsmpf::streaming::BoundedQueue::acquire ( )
inline

Acquire a ticket to send into the queue.

Returns
A coroutine to be awaited that provides a ticket (or std::nullopt if the queue is shutdown).

Definition at line 127 of file queue.hpp.

◆ drain()

coro::task<void> rapidsmpf::streaming::BoundedQueue::drain ( std::unique_ptr< coro::thread_pool > &  executor)
inline

Drain all messages in the queue and shut down.

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

Definition at line 157 of file queue.hpp.

◆ raii_shutdown()

BoundedQueue::Shutdown rapidsmpf::streaming::BoundedQueue::raii_shutdown ( )
inlinenoexcept

Obtain an object that will synchronously shutdown the queue when it goes out of scope.

Returns
A shutdown object.

Definition at line 179 of file queue.hpp.

◆ receive()

coro::task<std::pair<coro::task<void>, Message> > rapidsmpf::streaming::BoundedQueue::receive ( )
inline

Receive a message from the queue.

Returns
A coroutine containing the release task and the received message (or a null task and an empty message if the queue is shut down).

Definition at line 141 of file queue.hpp.

◆ shutdown()

coro::task<void> rapidsmpf::streaming::BoundedQueue::shutdown ( )
inline

Immediately shut down the queue.

Any pending or future operations will complete with failure.

Returns
A coroutine representing the shutdown.

Definition at line 169 of file queue.hpp.


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