Lunchbox  1.6.0
Public Member Functions
lunchbox::LFQueue< T > Class Template Reference

A thread-safe, lock-free queue with non-blocking access. More...

#include <lfQueue.h>

+ Inheritance diagram for lunchbox::LFQueue< T >:
+ Collaboration diagram for lunchbox::LFQueue< T >:

List of all members.

Public Member Functions

 LFQueue (const int32_t size)
 Construct a new queue.
 ~LFQueue ()
 Destruct this queue.
bool isEmpty () const
void clear ()
 Reset (empty) the queue.
void resize (const int32_t size)
 Resize and reset the queue.
bool pop (T &result)
 Retrieve and pop the front element from the queue.
bool getFront (T &result)
 Retrieve the front element from the queue.
bool push (const T &element)
 Push a new element to the back of the queue.
size_t getCapacity () const

Detailed Description

template<typename T>
class lunchbox::LFQueue< T >

A thread-safe, lock-free queue with non-blocking access.

Typically used for caches and non-blocking communication between two execution threads.

Current implementation constraints:

Definition at line 44 of file lfQueue.h.


Constructor & Destructor Documentation

template<typename T >
lunchbox::LFQueue< T >::LFQueue ( const int32_t  size) [inline]

Construct a new queue.

Version:
1.0

Definition at line 48 of file lfQueue.h.

template<typename T >
lunchbox::LFQueue< T >::~LFQueue ( ) [inline]

Destruct this queue.

Version:
1.0

Definition at line 52 of file lfQueue.h.


Member Function Documentation

template<typename T >
void lunchbox::LFQueue< T >::clear ( ) [inline]

Reset (empty) the queue.

Version:
1.0

Definition at line 58 of file lfQueue.h.

template<typename T >
size_t lunchbox::LFQueue< T >::getCapacity ( ) const [inline]
Returns:
the maximum number of elements held by the queue.
Version:
1.0

Definition at line 139 of file lfQueue.h.

template<typename T >
bool lunchbox::LFQueue< T >::getFront ( T &  result) [inline]

Retrieve the front element from the queue.

Parameters:
resultthe front value or unmodified
Returns:
true if an element was placed in result, false if the queue is empty.
Version:
1.0

Definition at line 106 of file lfQueue.h.

template<typename T >
bool lunchbox::LFQueue< T >::isEmpty ( ) const [inline]
Returns:
true if the queue is empty, false otherwise.
Version:
1.0

Definition at line 55 of file lfQueue.h.

Referenced by lunchbox::LFQueue< T >::resize().

+ Here is the caller graph for this function:

template<typename T >
bool lunchbox::LFQueue< T >::pop ( T &  result) [inline]

Retrieve and pop the front element from the queue.

Parameters:
resultthe front value or unmodified
Returns:
true if an element was placed in result, false if the queue is empty.
Version:
1.0

Definition at line 87 of file lfQueue.h.

template<typename T >
bool lunchbox::LFQueue< T >::push ( const T &  element) [inline]

Push a new element to the back of the queue.

Parameters:
elementthe element to add.
Returns:
true if the element was placed, false if the queue is full
Version:
1.0

Definition at line 123 of file lfQueue.h.

template<typename T >
void lunchbox::LFQueue< T >::resize ( const int32_t  size) [inline]

Resize and reset the queue.

This method is not thread-safe. The queue has to be empty.

Version:
1.0

Definition at line 71 of file lfQueue.h.

References lunchbox::LFQueue< T >::isEmpty().

+ Here is the call graph for this function:


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