|
Jamba C++ API 7.5.0
|
This class implements a queue which has at most 1 element (0 or 1). More...
#include <Concurrent.h>
Public Member Functions | |
| bool | isEmpty () const |
| Note that although this api is thread safe, it will only report the state of the queue at the moment it is called. | |
| bool | pop (T &oElement) |
| Returns the single element in the queue if there is one. | |
| bool | pop (T *oElement) |
| Returns the single element in the queue if there is one. | |
| void | push (T const &iElement) |
| Pushes one element in the queue. | |
| void | push (T const *iElement) |
| Pushes one element in the queue. | |
| SingleElementQueue () | |
| SingleElementQueue (std::unique_ptr< T > iFirstElement, bool iIsEmpty=false) | |
| This constructor can be used to add one element to the queue right away or when there is no empty constructor (required by the no argument constructor). | |
Private Attributes | |
| bool | fIsEmpty |
| std::unique_ptr< T > | fSingleElement |
| SpinLock | fSpinLock |
This class implements a queue which has at most 1 element (0 or 1).
If there is already an element and the push method is called again, it will replace the current element. This implementation uses a SpinLock and is thread safe to be called by any number of threads. This implementation does not allocate any memory and is expecting the T type to have an empty constructor and operator=.
|
inline |
|
inlineexplicit |
This constructor can be used to add one element to the queue right away or when there is no empty constructor (required by the no argument constructor).
|
inline |
Note that although this api is thread safe, it will only report the state of the queue at the moment it is called.
You should not assume that because isEmpty() returns false, then pop will return true!
|
inline |
Returns the single element in the queue if there is one.
| oElement | this will be populated with the value of the element in the queue or left untouched if there isn't one |
|
inline |
Returns the single element in the queue if there is one.
| oElement | this will be populated with the value of the element in the queue or left untouched if there isn't one |
|
inline |
Pushes one element in the queue.
If the queue already had an element it will be replaced.
| iElement | the element to push (clearly not modified by the call) |
|
inline |
Pushes one element in the queue.
If the queue already had an element it will be replaced.
| iElement | the element to push (clearly not modified by the call) |
|
private |
|
private |
|
mutableprivate |