![]() |
MySQL 26.7.0
Source Code Documentation
|
Synchronized unbounded FIFO queue for thread-safe producer-consumer operations, using a single mutex and condition variable. More...
#include <locking_queue.h>
Public Types | |
| using | ElemType = ET |
| using | Memory_resource = mysql::allocators::Memory_resource |
Public Member Functions | |
| Locking_queue (Memory_resource memory_resource={}) | |
| Constructs the queue. More... | |
| Locking_queue (const Locking_queue< ElemType > &)=delete | |
| Locking_queue (Locking_queue< ElemType > &&)=delete | |
| Locking_queue & | operator= (const Locking_queue< ElemType > &src)=delete |
| Locking_queue & | operator= (Locking_queue< ElemType > &&src)=delete |
| ~Locking_queue ()=default | |
| bool | enqueue (ElemType &&elem) |
| Enqueues an element into the queue (called by producers). More... | |
| bool | empty () const |
| Checks if the queue is empty. More... | |
| template<typename P > | |
| std::pair< ElemType, bool > | dequeue (P &&pred) |
| Consumes (dequeues) an element from the front of the queue. More... | |
| void | notify_all () |
| Wakes all waiting consumers (e.g., during shutdown to check pred and exit). More... | |
Private Attributes | |
| std::queue< ElemType > | m_queue |
| Underlying unbounded FIFO queue. More... | |
| concurrency::Mutex | m_mutex_access_queue |
| Mutex protecting all queue operations. More... | |
| concurrency::Condition_variable | m_cv_empty_queue |
| Condition variable for waiting on non-empty queue. More... | |
| Memory_resource | m_memory_resource |
| Reserved for future custom allocation; currently unused. More... | |
Synchronized unbounded FIFO queue for thread-safe producer-consumer operations, using a single mutex and condition variable.
This queue is unbounded (enqueue always succeeds). For performance, it does not enforce safe destruction during concurrent access. Ensure the queue outlives all producers and consumers to avoid undefined behavior.
| using mysql::concurrency::Locking_queue< ET >::ElemType = ET |
| using mysql::concurrency::Locking_queue< ET >::Memory_resource = mysql::allocators::Memory_resource |
|
inline |
Constructs the queue.
The memory_resource is reserved for future use (e.g., custom allocation for elements) and currently unused.
|
delete |
|
delete |
|
default |
|
inline |
Consumes (dequeues) an element from the front of the queue.
Blocks until an element is available or the stop predicate triggers.
| pred | Stop predicate (callable); if pred() returns true after waking, stops waiting and returns without consuming. |
|
inline |
Checks if the queue is empty.
Acquires the mutex for thread-safe access. Due to concurrent enqueues/consumes, the result is a snapshot and may change immediately after the call.
|
inline |
Enqueues an element into the queue (called by producers).
| elem | Element to enqueue (moved). |
Acquires the mutex, pushes the element to the back, notifies one waiting consumer, then releases the mutex.
|
inline |
Wakes all waiting consumers (e.g., during shutdown to check pred and exit).
Notifies all on the condition variable, unblocking blocked consumes.
|
delete |
|
delete |
|
private |
Condition variable for waiting on non-empty queue.
|
private |
Reserved for future custom allocation; currently unused.
|
mutableprivate |
Mutex protecting all queue operations.
|
private |
Underlying unbounded FIFO queue.