This is the lock free version of the SingleElementQueue.
More...
#include <Concurrent.h>
Inherits SingleElementStorage< T >.
|
T const * | last () const |
|
void | last (T &oElement) const |
| Copy the last value that was popped to oElement. More...
|
|
T * | pop () |
|
bool | pop (T &oElement) |
| Copy the popped value to oElement and return true when there is a new value otherwise do nothing and return false. More...
|
|
T const * | popOrLast () |
|
void | popOrLast (T &oElement) |
| Copy either the new value (if there is one) or the last value that was popped to oElement. More...
|
|
void | push (T const &iElement) |
| Pushes (a copy of) iElement in the queue. More...
|
|
void | push (T const *iElement) |
| Pushes (a copy of) *iElement in the queue. More...
|
|
| SingleElementQueue () |
|
| SingleElementQueue (std::unique_ptr< T > iElement, bool iIsEmpty=false) |
| This constructor should be used if T does not provide an empty constructor. More...
|
|
template<class ElementModifier > |
void | updateAndPush (ElementModifier const &iElementModifier) |
| Use this flavor of push to avoid copy. More...
|
|
template<class ElementModifier > |
bool | updateAndPushIf (ElementModifier const &iElementModifier) |
| Use this flavor of push to avoid copy. More...
|
|
bool | __isLockFree () const |
| Used (from test) to make sure that it is a lock free implementation. More...
|
|
bool | isEmpty () const |
|
| SingleElementStorage (std::unique_ptr< T > iElement, bool iIsEmpty) noexcept |
|
| ~SingleElementStorage () |
|
template<typename T>
class pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >
This is the lock free version of the SingleElementQueue.
Internally it uses a different pointer for push and pop. As described in the comment for SingleElementStorage, all methods related to 'pop' can be called in one thread while all methods related to 'push' can be called by another.
◆ Element
◆ SingleElementQueue() [1/2]
◆ SingleElementQueue() [2/2]
This constructor should be used if T does not provide an empty constructor.
◆ last() [1/2]
- Returns
- returns the last value that was popped (never nullptr). Does NOT check for new value
◆ last() [2/2]
void last |
( |
T & |
oElement | ) |
const |
|
inline |
Copy the last value that was popped to oElement.
Does NOT check for new value
◆ pop() [1/2]
- Returns
- the value popped or nullptr if nothing to pop
◆ pop() [2/2]
Copy the popped value to oElement and return true when there is a new value otherwise do nothing and return false.
◆ popOrLast() [1/2]
- Returns
- if there is a new value to pop, returns it otherwise return the last value that was popped (never nullptr)
◆ popOrLast() [2/2]
void popOrLast |
( |
T & |
oElement | ) |
|
|
inline |
Copy either the new value (if there is one) or the last value that was popped to oElement.
◆ push() [1/2]
void push |
( |
T const & |
iElement | ) |
|
|
inline |
Pushes (a copy of) iElement in the queue.
◆ push() [2/2]
void push |
( |
T const * |
iElement | ) |
|
|
inline |
Pushes (a copy of) *iElement in the queue.
◆ pushValue()
◆ updateAndPush()
void updateAndPush |
( |
ElementModifier const & |
iElementModifier | ) |
|
|
inline |
Use this flavor of push to avoid copy.
ElementModifier will be called back with the internal pointer to update it.
◆ updateAndPushIf()
bool updateAndPushIf |
( |
ElementModifier const & |
iElementModifier | ) |
|
|
inline |
Use this flavor of push to avoid copy.
ElementModifier will be called back with the internal pointer to update it. This flavor uses a callback that returns true when the push should happen and false otherwise.
◆ fPopValue
◆ fPushValue
std::unique_ptr<Element> fPushValue |
|
private |
The documentation for this class was generated from the following file: