Impact Acquire SDK C++
|
A thread-safe queue. More...
#include <mvIMPACT_acquire_helper.h>
Public Types | |
enum | TQueueResult { qrNoError = 0 , qrFull , qrLocked } |
Defines valid queue result values. More... | |
Public Member Functions | |
void | clear (void) |
Clears the queue. Discards all data. | |
bool | front (T *pData=nullptr) const |
Gets a copy of the oldest element from the queue. | |
std::queue< T >::size_type | getCurrentSize (void) const |
Returns the current number of elements stored by this queue. | |
std::queue< T >::size_type | getMaxSize (void) const |
Returns the maximum number of elements this queue can store. | |
bool | isFull (void) const |
Checks if this queue is currently full. | |
bool | lock (void) |
Locks the queue. | |
ThreadSafeQueue & | operator= (const ThreadSafeQueue &rhs)=delete |
assignment operator (deleted) | |
template<class Rep , class Period > | |
bool | pop (const std::chrono::duration< Rep, Period > &rel_time, T *pData=nullptr) |
Removes the oldest element from the queue, effectively reducing its size by one. | |
bool | pop (T *pData=nullptr) |
Removes the oldest element from the queue, effectively reducing its size by one. | |
bool | pop (unsigned int timeout_ms, T *pData=nullptr) |
Removes the oldest element from the queue, effectively reducing its size by one. | |
TQueueResult | push (const T &t) |
Adds a new copy of an element to the queue. | |
void | terminateWait (void) |
Terminates a single wait operation currently pending from another thread without delivering data. | |
ThreadSafeQueue (const ThreadSafeQueue &src)=delete | |
Copy-constructor (deleted) | |
ThreadSafeQueue (typename std::queue< T >::size_type queueSizeMax=std::numeric_limits< typename std::queue< T >::size_type >::max()) | |
Creates a new mvIMPACT::acquire::helper::ThreadSafeQueue instance. | |
bool | unlock (void) |
Unlocks the queue. | |
A thread-safe queue.
This class provides a thread-safe queue implementation with all the operations typically needed within a multi-threaded environment.
enum TQueueResult |
Defines valid queue result values.
These enumeration defines valid values that might be returned from some of the queue operations defined by the surrounding mvIMPACT::acquire::helper::ThreadSafeQueue class.
|
inlineexplicit |
Creates a new mvIMPACT::acquire::helper::ThreadSafeQueue instance.
[in] | queueSizeMax | The maximum number of elements this queue shall be allowed to store until another push operation will fail. |
|
delete |
Copy-constructor (deleted)
Objects of this type shall not be copy-constructed!
|
inline |
Clears the queue. Discards all data.
|
inline |
Gets a copy of the oldest element from the queue.
Gets a copy of the oldest element in the queue and the same element that is popped out from the queue when mvIMPACT::acquire::helper::ThreadSafeQueue::pop is called.
[in,out] | pData | A pointer to the storage location that shall receive a copy of the oldest element currently stored in the queue. Can be nullptr if a caller just wants to check if there is at least one element stored be the queue right now. |
|
inline |
Returns the current number of elements stored by this queue.
|
inline |
Returns the maximum number of elements this queue can store.
When trying to push more elements into the queue than returned by this function the next mvIMPACT::acquire::helper::ThreadSafeQueue::push call will fail until at least one element has been extracted before. The maximum number of elements a queue can store can be specified when constructing the queue.
|
inline |
Checks if this queue is currently full.
|
inline |
Locks the queue.
While a queue is locked subsequent calls to mvIMPACT::acquire::helper::ThreadSafeQueue::push will fail and will return mvIMPACT::acquire::helper::ThreadSafeQueue::qrLocked.
|
delete |
assignment operator (deleted)
Objects of this type shall not be assigned!
|
inline |
Removes the oldest element from the queue, effectively reducing its size by one.
Removes the oldest element from the queue, effectively reducing its size by one.
[in] | rel_time | The maximum time to wait for incoming data if the queue currently does not contain any data to pick up. |
[in,out] | pData | A pointer to the storage location that shall receive a copy of the oldest element currently stored in the queue. Can be nullptr if a caller just wants to remove an element from the queue but is not actually interested in it. |
|
inline |
Removes the oldest element from the queue, effectively reducing its size by one.
Removes the oldest element from the queue, effectively reducing its size by one.
[in,out] | pData | A pointer to the storage location that shall receive a copy of the oldest element currently stored in the queue. Can be nullptr if a caller just wants to remove an element from the queue but is not actually interested in it. |
|
inline |
Removes the oldest element from the queue, effectively reducing its size by one.
Removes the oldest element from the queue, effectively reducing its size by one.
[in] | timeout_ms | The maximum time (in mill-seconds) to wait for incoming data if the queue currently does not contain any data to pick up. |
[in,out] | pData | A pointer to the storage location that shall receive a copy of the oldest element currently stored in the queue. Can be nullptr if a caller just wants to remove an element from the queue but is not actually interested in it. |
|
inline |
Adds a new copy of an element to the queue.
Adds a new copy of an element to the queue.
[in] | t | A const reference to the element to store in the queue. The object must be copy-constructible as this operation will create a copy of the object. |
|
inline |
Terminates a single wait operation currently pending from another thread without delivering data.
If one or multiple thread(s) are currently executing a mvIMPACT::acquire::helper::ThreadSafeQueue::pop operation ONE of these threads will get signaled and the call will return.
|
inline |
Unlocks the queue.
While a queue is locked subsequent calls to mvIMPACT::acquire::helper::ThreadSafeQueue::push will fail and will return mvIMPACT::acquire::helper::ThreadSafeQueue::qrLocked.