rogue
Loading...
Searching...
No Matches
Public Member Functions | List of all members
rogue::Queue< T > Class Template Reference

Thread-safe bounded queue with optional busy threshold. More...

#include <Queue.h>

Public Member Functions

 Queue ()
 Constructs an empty running queue.
 
void stop ()
 Stops queue operation and wakes blocked producers/consumers.
 
void setMax (uint32_t max)
 Sets maximum queue depth before push() blocks.
 
void setThold (uint32_t thold)
 Sets busy-threshold depth used by busy().
 
void push (T const &data)
 Pushes one entry, blocking when queue is full.
 
bool empty ()
 Returns whether queue is currently empty.
 
uint32_t size ()
 Returns current queue depth.
 
bool busy ()
 Returns busy state based on configured threshold.
 
void reset ()
 Clears all queued entries and resets busy state.
 
T pop ()
 Pops one entry, blocking until data is available or stopped.
 

Detailed Description

template<typename T>
class rogue::Queue< T >

Thread-safe bounded queue with optional busy threshold.

Queue<T> supports producer/consumer usage with blocking push()/pop(). setMax() configures the maximum queued depth before push() blocks. setThold() configures a busy threshold used by busy(). stop() wakes blocked waiters and causes subsequent blocking calls to exit.

Definition at line 38 of file Queue.h.

Constructor & Destructor Documentation

◆ Queue()

template<typename T >
rogue::Queue< T >::Queue ( )
inline

Constructs an empty running queue.

Definition at line 51 of file Queue.h.

Member Function Documentation

◆ busy()

template<typename T >
bool rogue::Queue< T >::busy ( )
inline

Returns busy state based on configured threshold.

Returns
true when thold_ > 0 and queue depth is at/above threshold.

Definition at line 123 of file Queue.h.

◆ empty()

template<typename T >
bool rogue::Queue< T >::empty ( )
inline

Returns whether queue is currently empty.

Returns
true when no entries are queued.

Definition at line 106 of file Queue.h.

◆ pop()

template<typename T >
T rogue::Queue< T >::pop ( )
inline

Pops one entry, blocking until data is available or stopped.

Returns
Popped entry when running; default-initialized T when stopped.

Definition at line 141 of file Queue.h.

◆ push()

template<typename T >
void rogue::Queue< T >::push ( T const &  data)
inline

Pushes one entry, blocking when queue is full.

Parameters
dataEntry to enqueue.

Definition at line 92 of file Queue.h.

◆ reset()

template<typename T >
void rogue::Queue< T >::reset ( )
inline

Clears all queued entries and resets busy state.

Definition at line 130 of file Queue.h.

◆ setMax()

template<typename T >
void rogue::Queue< T >::setMax ( uint32_t  max)
inline

Sets maximum queue depth before push() blocks.

0 disables the depth limit.

Parameters
maxMaximum queued entries.

Definition at line 76 of file Queue.h.

◆ setThold()

template<typename T >
void rogue::Queue< T >::setThold ( uint32_t  thold)
inline

Sets busy-threshold depth used by busy().

Parameters
tholdQueue depth threshold.

Definition at line 84 of file Queue.h.

◆ size()

template<typename T >
uint32_t rogue::Queue< T >::size ( )
inline

Returns current queue depth.

Returns
Number of queued entries.

Definition at line 114 of file Queue.h.

◆ stop()

template<typename T >
void rogue::Queue< T >::stop ( )
inline

Stops queue operation and wakes blocked producers/consumers.

Definition at line 61 of file Queue.h.


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