24#ifndef GCS_MPSC_QUEUE_INCLUDED
25#define GCS_MPSC_QUEUE_INCLUDED
39template <
typename T,
typename Deleter = std::default_delete<T>>
58 m_next.store(
nullptr, std::memory_order_relaxed);
73 return m_next.load(memory_order);
82 m_next.store(node, memory_order);
102 std::atomic<Gcs_mpsc_queue_node *>
m_next;
123 for (T *payload =
pop(); payload !=
nullptr; payload =
pop()) {
127 assert(
m_tail ==
m_head.load(std::memory_order_relaxed));
142 bool successful =
false;
144 if (new_node !=
nullptr) {
146 m_head.exchange(new_node, std::memory_order_acq_rel);
147 previous->
set_next(new_node, std::memory_order_release);
176 std::atomic<Gcs_mpsc_queue_node *>
m_head;
Definition: tls_cipher.cc:37
Node that holds an element (payload) of the MPSC queue.
Definition: gcs_mpsc_queue.h:45
T * m_payload
The payload.
Definition: gcs_mpsc_queue.h:106
Gcs_mpsc_queue_node(Gcs_mpsc_queue_node &&)=delete
Gcs_mpsc_queue_node & operator=(Gcs_mpsc_queue_node const &)=delete
void set_next(Gcs_mpsc_queue_node *node, std::memory_order memory_order)
Links a node to this node.
Definition: gcs_mpsc_queue.h:81
Gcs_mpsc_queue_node()
Creates an unlinked and empty node.
Definition: gcs_mpsc_queue.h:50
std::atomic< Gcs_mpsc_queue_node * > m_next
The next node in the linked list.
Definition: gcs_mpsc_queue.h:102
Gcs_mpsc_queue_node(T *initial_payload)
Creates an unlinked node with the given payload.
Definition: gcs_mpsc_queue.h:57
Gcs_mpsc_queue_node * get_next(std::memory_order memory_order)
Gets the next node in the linked list.
Definition: gcs_mpsc_queue.h:72
Gcs_mpsc_queue_node & operator=(Gcs_mpsc_queue_node &&)=delete
Gcs_mpsc_queue_node(Gcs_mpsc_queue_node const &)=delete
T * extract_payload()
Extracts the payload from this node.
Definition: gcs_mpsc_queue.h:92
MPSC queue with FIFO semantics.
Definition: gcs_mpsc_queue.h:40
Gcs_mpsc_queue_node * m_tail
Definition: gcs_mpsc_queue.h:175
Gcs_mpsc_queue & operator=(Gcs_mpsc_queue &&)=delete
std::atomic< Gcs_mpsc_queue_node * > m_head
Definition: gcs_mpsc_queue.h:176
Gcs_mpsc_queue(Deleter custom_deleter)
Definition: gcs_mpsc_queue.h:114
Gcs_mpsc_queue(Gcs_mpsc_queue &&)=delete
Deleter m_payload_deleter
Definition: gcs_mpsc_queue.h:174
T * pop()
Attempt to retrieve the first element from the queue.
Definition: gcs_mpsc_queue.h:160
Gcs_mpsc_queue & operator=(Gcs_mpsc_queue const &)=delete
~Gcs_mpsc_queue()
Destroy the queued nodes.
Definition: gcs_mpsc_queue.h:121
Gcs_mpsc_queue()
Create an empty queue.
Definition: gcs_mpsc_queue.h:113
bool push(T *payload)
Insert payload at the end of the queue.
Definition: gcs_mpsc_queue.h:141
Gcs_mpsc_queue(Gcs_mpsc_queue const &)=delete
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
static std::atomic< uchar * > & next_node(LF_PINBOX *P, uchar *X)
Definition: lf_alloc-pin.cc:350
struct result result
Definition: result.h:34