#include <queue.h>
Public Member Functions | |
LockFreeQueue () | |
constructor | |
~LockFreeQueue () | |
destructor | |
void | enqueue (T d) |
insert an element into the tail of queue. Thread-safe | |
bool | dequeue (T &ret) |
remove and return an element from the head of queue. Thread-safe. | |
bool | empty () |
Check to see if queue is empty. Thread-safe. | |
int | size () |
Get the size of the queue at this point. compute on the fly. Not thread-safe. | |
bool | peekFront (T &top) |
Get the first element of the queue. If the queue is empty return false, else return true and assign the first to the parameter. Thread-safe. | |
Classes | |
class | Node |
However, from its performance test, SPAA05's scales much better than PODC96's when number of CPU cores are large, but performs slower when few CPU cores available. We decide to implement PODC96's for its simplicity and applicability
Performance tuning tips: 1 backoff mechanism. 2 Eliminate redundant memory barriers, implied by the atomics. Use atomic_xx_xx instead of neat C++ APIs, which are easy to use, but always imply full barriers currently. TODO: 1 code it in STL code style
T | The type of the element which is stored in the queue |
amino::LockFreeQueue< T >::LockFreeQueue | ( | ) | [inline] |
constructor
amino::LockFreeQueue< T >::~LockFreeQueue | ( | ) | [inline] |
destructor
void amino::LockFreeQueue< T >::enqueue | ( | T | d | ) | [inline] |
insert an element into the tail of queue. Thread-safe
d | The element to be added |
bool amino::LockFreeQueue< T >::dequeue | ( | T & | ret | ) | [inline] |
remove and return an element from the head of queue. Thread-safe.
bool amino::LockFreeQueue< T >::empty | ( | ) | [inline] |
Check to see if queue is empty. Thread-safe.
int amino::LockFreeQueue< T >::size | ( | ) | [inline] |
Get the size of the queue at this point. compute on the fly. Not thread-safe.
bool amino::LockFreeQueue< T >::peekFront | ( | T & | top | ) | [inline] |
Get the first element of the queue. If the queue is empty return false, else return true and assign the first to the parameter. Thread-safe.
ret | The first element of the queue. It is valid if return true. |