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() . | |
Public Member Functions | |
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. | |
void | SwapUnsafe (LockFreeBroadcastQueue &rhs) noexcept |
Swaps an object. This is not thread-safe. | |
Constructor, Destructor, and Initialization | |
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... | |
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 739 of file LockFree.h.
|
inlinenoexcept |
Destructor.
DestructorForLockFree
to delete each of remaining elements, if any. If necessary, specialize a function template to perform necessary processing.. Definition at line 746 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 761 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 757 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 753 of file LockFree.h.
© Nintendo Co., Ltd. All rights reserved.