Wraps nlib_mq
with a class implementing a lock-free queue with a priority set.
More...
#include "nn/nlib/LockFree.h"
template<class T>
class nn::nlib::LockFreePriorityQueue< T >
Wraps nlib_mq
with a class implementing a lock-free queue with a priority set.
- Template Parameters
-
- Description
- If necessary,
DestructorForLockFree<T>
must be specialized to write code for destructing elements of the type T
. If Enqueue()
is executed while Dequeue()
is being executed, Dequeue()
may not return the element with the highest priority.
Definition at line 650 of file LockFree.h.
◆ DequeueType
◆ ~LockFreePriorityQueue()
Destructor.
- Description
- Any elements remaining in the queue are destructed by
DestructorForLockFree<T>
.
Definition at line 656 of file LockFree.h.
◆ Close()
Closes the queue and restores it to the state before its initialization. This is not thread-safe.
- Returns
- Returns
0
on success.
- Description
- Any elements remaining in the queue are destructed by
DestructorForLockFree<T>
.
Definition at line 671 of file LockFree.h.
◆ Dequeue()
Picks up an element from the queue. This is thread-safe.
- Parameters
-
[out] | obj | An object picked up from the queue. |
[out] | prio | The priority of obj. |
- Returns
- The value returned by
nlib_mq_receive()
.
Definition at line 681 of file LockFree.h.
◆ Enqueue()
Adds an element to the queue. This is thread-safe.
- Parameters
-
[in] | obj | A pointer to the element. |
[in] | prio | The priority in the range of 0 to 31 inclusive. |
- Returns
- The value returned by
nlib_mq_send()
.
Definition at line 677 of file LockFree.h.
◆ Init()
Initializes the queue. This is not thread-safe.
- Parameters
-
[in] | max_size | The maximum number of elements that can be stored in the queue. |
- Return values
-
0 | Success. |
EINVAL | max_size exceeds INT32_MAX . |
EALREADY | Already initialized. |
Other | errors returned by nlib_mq_open() . |
Definition at line 660 of file LockFree.h.
The documentation for this class was generated from the following files: