Seastar
High performance C++ framework for concurrent servers
Public Member Functions | List of all members
seastar::queue< T > Class Template Reference

Detailed Description

template<typename T>
class seastar::queue< T >

Asynchronous single-producer single-consumer queue with limited capacity. There can be at most one producer-side and at most one consumer-side operation active at any time. Operations returning a future are considered to be active until the future resolves.

#include <seastar/core/queue.hh>

Public Member Functions

 queue (size_t size)
 
bool push (T &&a)
 Push an item. More...
 
pop ()
 Pop an item. More...
 
template<typename Func >
bool consume (Func &&func)
 
bool empty () const
 Returns true when the queue is empty.
 
bool full () const
 Returns true when the queue is full.
 
future not_empty ()
 
future not_full ()
 
future< T > pop_eventually ()
 
future push_eventually (T &&data)
 
size_t size () const
 Returns the number of items currently in the queue.
 
size_t max_size () const
 
void set_max_size (size_t max)
 
void abort (std::exception_ptr ex)
 
bool has_blocked_consumer () const
 Check if there is an active consumer. More...
 

Member Function Documentation

◆ abort()

template<typename T >
void seastar::queue< T >::abort ( std::exception_ptr  ex)
inline

Destroy any items in the queue, and pass the provided exception to any waiting readers or writers - or to any later read or write attempts.

◆ consume()

template<typename T >
template<typename Func >
bool seastar::queue< T >::consume ( Func &&  func)
inline

Consumes items from the queue, passing them to func, until func returns false or the queue it empty

Returns false if func returned false.

◆ has_blocked_consumer()

template<typename T >
bool seastar::queue< T >::has_blocked_consumer ( ) const
inline

Check if there is an active consumer.

Returns true if another fiber waits for an item to be pushed into the queue

◆ max_size()

template<typename T >
size_t seastar::queue< T >::max_size ( ) const
inline

Returns the size limit imposed on the queue during its construction or by a call to set_max_size(). If the queue contains max_size() items (or more), further items cannot be pushed until some are popped.

◆ not_empty()

template<typename T >
future seastar::queue< T >::not_empty
inline

Returns a future<> that becomes available when pop() or consume() can be called. A consumer-side operation. Cannot be called concurrently with other consumer-side operations.

◆ not_full()

template<typename T >
future seastar::queue< T >::not_full
inline

Returns a future<> that becomes available when push() can be called. A producer-side operation. Cannot be called concurrently with other producer-side operations.

◆ pop()

template<typename T >
T seastar::queue< T >::pop
inline

Pop an item.

Popping from an empty queue will result in undefined behavior.

◆ pop_eventually()

template<typename T >
future< T > seastar::queue< T >::pop_eventually
inline

Pops element now or when there is some. Returns a future that becomes available when some element is available. If the queue is, or already was, abort()ed, the future resolves with the exception provided to abort(). A consumer-side operation. Cannot be called concurrently with other consumer-side operations.

◆ push()

template<typename T >
bool seastar::queue< T >::push ( T &&  a)
inline

Push an item.

Returns false if the queue was full and the item was not pushed.

◆ push_eventually()

template<typename T >
future seastar::queue< T >::push_eventually ( T &&  data)
inline

Pushes the element now or when there is room. Returns a future<> which resolves when data was pushed. If the queue is, or already was, abort()ed, the future resolves with the exception provided to abort(). A producer-side operation. Cannot be called concurrently with other producer-side operations.

◆ set_max_size()

template<typename T >
void seastar::queue< T >::set_max_size ( size_t  max)
inline

Set the maximum size to a new value. If the queue's max size is reduced, items already in the queue will not be expunged and the queue will be temporarily bigger than its max_size.


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