Public Member Functions | List of all members
ArrayBlockingQueue< T > Class Template Reference

A blocking queue that uses wait/notify and an array to hold the elements. More...

#include <ArrayBlockingQueue.hpp>

Inheritance diagram for ArrayBlockingQueue< T >:
[legend]
Collaboration diagram for ArrayBlockingQueue< T >:
[legend]

Public Member Functions

 ArrayBlockingQueue (unsigned int capacity)
 Create an array blocking queue with the specified capacity. More...
 
dequeue () override
 Dequeue an object, waiting for an object to become available if the queue is empty. More...
 
bool empty () const override
 Returns true if the queue is empty. More...
 
void enqueue (T &&element) override
 Enqueue an object, waiting for space to be available if the queue is full. More...
 
bool full () const override
 Returns true if the queue is full. More...
 
tryDequeue () override
 Try to dequeue an object. More...
 
tryDequeue (std::chrono::milliseconds waitTime) override
 Try to dequeue an object, waiting for the specified time if the queue is empty. More...
 

Detailed Description

template<typename T>
class Balau::Container::ArrayBlockingQueue< T >

A blocking queue that uses wait/notify and an array to hold the elements.

This queue is concurrent but not lock free.

Template Parameters
Tthe element type (must be default constructable in addition being move constructable and assignable)

Constructor & Destructor Documentation

◆ ArrayBlockingQueue()

ArrayBlockingQueue ( unsigned int  capacity)
inlineexplicit

Create an array blocking queue with the specified capacity.

Member Function Documentation

◆ dequeue()

T dequeue ( )
inlineoverridevirtual

Dequeue an object, waiting for an object to become available if the queue is empty.

Implements BlockingQueue< T >.

◆ empty()

bool empty ( ) const
inlineoverridevirtual

Returns true if the queue is empty.

Given the concurrent nature of block queues, this operation is approximate.

Implements BlockingQueue< T >.

◆ enqueue()

void enqueue ( T &&  element)
inlineoverridevirtual

Enqueue an object, waiting for space to be available if the queue is full.

The supplied element is moved during enqueuing.

Implements BlockingQueue< T >.

◆ full()

bool full ( ) const
inlineoverridevirtual

Returns true if the queue is full.

Given the concurrent nature of block queues, this operation is approximate.

Implements BlockingQueue< T >.

◆ tryDequeue() [1/2]

T tryDequeue ( )
inlineoverridevirtual

Try to dequeue an object.

if no dequeue was made, a default constructed object is returned.

Implements BlockingQueue< T >.

◆ tryDequeue() [2/2]

T tryDequeue ( std::chrono::milliseconds  waitTime)
inlineoverridevirtual

Try to dequeue an object, waiting for the specified time if the queue is empty.

if no dequeue was made, a default constructed object is returned.

Implements BlockingQueue< T >.


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