nlib
|
The specified number of listeners can obtain elements from the queue. After all the listeners have obtained elements, those elements are deleted from the queue. More...
#include "nn/nlib/LockFree.h"
Public Types | |
typedef UniquePtr< const T, empty_func > | DequeueType |
The type for the argument of Dequeue() and DequeueUnsafe() . | |
Public Member Functions | |
LockFreeBroadcastQueue () noexcept | |
Instantiates the object with default parameters (default constructor). | |
~LockFreeBroadcastQueue () noexcept | |
Destructor. More... | |
errno_t | Init (size_t max_size, size_t listeners) noexcept |
Initializes the queue. This is not thread-safe. More... | |
errno_t | Enqueue (const T *obj) noexcept |
Adds an element to the queue. This is thread-safe. More... | |
errno_t | Dequeue (int32_t listener_id, DequeueType &obj) noexcept |
Specifies the listener and then reads an element from the queue. This is thread-safe when using a different listener_id. More... | |
size_t | GetListenerCount () const noexcept |
Returns the number of listeners specified in Init() . This is thread-safe. | |
The specified number of listeners can obtain elements from the queue. After all the listeners have obtained elements, those elements are deleted from the queue.
T | The queue element type. |
Definition at line 726 of file LockFree.h.
|
inlinenoexcept |
Destructor.
DestructorForLockFree<const T>
. Definition at line 733 of file LockFree.h.
|
inlinenoexcept |
Specifies the listener and then reads an element from the queue. This is thread-safe when using a different listener_id.
[in] | listener_id | An integer that is 0 or larger and less than the number of listeners specified in Init() . |
[out] | obj | The read element. |
0 | Success. |
EAGAIN | No new element that can be read is available in the queue. |
Dequeue()
is executed next time. Note that no element is deleted until Dequeue()
for all listeners has completed. Definition at line 748 of file LockFree.h.
|
inlinenoexcept |
Adds an element to the queue. This is thread-safe.
[in] | obj | The element to be added to the queue. |
0 | Success. |
EAGAIN | The queue is full. |
Definition at line 744 of file LockFree.h.
|
inlinenoexcept |
Initializes the queue. This is not thread-safe.
[in] | max_size | The maximum number of elements that can be stored in the queue. |
[in] | listeners | The number of listeners. |
0 | Success. |
EINVAL | max_size exceeds INT32_MAX. |
ENOMEM | Memory allocation has failed. |
Definition at line 740 of file LockFree.h.
© 2013, 2014, 2015 Nintendo Co., Ltd. All rights reserved.