20#ifndef __circular_queue_mp_h
21#define __circular_queue_mp_h
26#include "interrupts.h"
37template<
typename T,
typename ForEachArg =
void >
67 esp8266::InterruptLock lock;
69 std::lock_guard<std::mutex> lock(
m_pushMtx);
74 bool IRAM_ATTR
push() =
delete;
82 bool IRAM_ATTR
push(T&& val)
85 esp8266::InterruptLock lock;
87 std::lock_guard<std::mutex> lock(
m_pushMtx);
98 bool IRAM_ATTR
push(
const T& val)
101 esp8266::InterruptLock lock;
103 std::lock_guard<std::mutex> lock(
m_pushMtx);
115 size_t push_n(
const T* buffer,
size_t size)
118 esp8266::InterruptLock lock;
120 std::lock_guard<std::mutex> lock(
m_pushMtx);
147template<
typename T,
typename ForEachArg >
151 esp8266::InterruptLock lock;
153 std::lock_guard<std::mutex> lock(m_pushMtx);
167template<
typename T,
typename ForEachArg >
173 if (outPos == inPos0)
return false;
179 esp8266::InterruptLock lock;
181 std::lock_guard<std::mutex> lock(m_pushMtx);
196 }
while (outPos != inPos0);
Definition Delegate.h:2049
Instance class for a multi-producer, single-consumer circular queue / ring buffer (FIFO)....
Definition circular_queue_mp.h:39
bool IRAM_ATTR push(T &&val)
Move the rvalue parameter into the queue, guarded for multiple concurrent producers.
Definition circular_queue_mp.h:82
size_t push_n(const T *buffer, size_t size)
Push copies of multiple elements from a buffer into the queue, in order, beginning at buffer's head....
Definition circular_queue_mp.h:115
circular_queue_mp(const size_t capacity)
Definition circular_queue_mp.h:42
bool for_each_requeue(const Delegate< bool(T &), ForEachArg > &fun)
Iterate over, pop and optionally requeue each available element from the queue, calling back fun with...
Definition circular_queue_mp.h:168
circular_queue_mp(circular_queue< T, ForEachArg > &&cq)
Definition circular_queue_mp.h:44
bool IRAM_ATTR push()=delete
T & pop_requeue()
Pops the next available element from the queue, requeues it immediately.
Definition circular_queue_mp.h:148
bool IRAM_ATTR push(const T &val)
Push a copy of the parameter into the queue, guarded for multiple concurrent producers.
Definition circular_queue_mp.h:98
circular_queue_mp()=default
std::mutex m_pushMtx
Definition circular_queue_mp.h:143
bool capacity(const size_t cap)
Resize the queue. The available elements in the queue are preserved. This is not lock-free,...
Definition circular_queue_mp.h:64
Instance class for a single-producer, single-consumer circular queue / ring buffer (FIFO)....
Definition circular_queue.h:48
size_t push_n(const T *buffer, size_t size)
Push copies of multiple elements from a buffer into the queue, in order, beginning at buffer's head.
Definition circular_queue.h:282
void for_each(const Delegate< void(T &&), void > &fun)
T pop()
Definition circular_queue.h:309
size_t available() const
Definition circular_queue.h:111
void flush()
Definition circular_queue.h:103
size_t pop_n(T *buffer, size_t size)
Definition circular_queue.h:326
size_t capacity() const
Definition circular_queue.h:86
T peek() const
Definition circular_queue.h:133
size_t available_for_push() const
Definition circular_queue.h:121
bool for_each_rev_requeue(const Delegate< bool(T &), void > &fun)
bool IRAM_ATTR push() __attribute__((always_inline))
Release the next pending input value, accessible by pushpeek(), into the queue.
Definition circular_queue.h:156
void atomic_thread_fence(std::memory_order order) noexcept
Definition ghostl.h:49
T && move(T &t) noexcept
Definition ghostl.h:50
@ memory_order_relaxed
Definition ghostl.h:35
@ memory_order_release
Definition ghostl.h:37
@ memory_order_acquire
Definition ghostl.h:36