MySQL 8.0.40
Source Code Documentation
|
The class defines a type of queue with a predefined max capacity that is implemented using the circular memory buffer. More...
#include <rpl_rli_pdb.h>
Public Member Functions | |
circular_buffer_queue (size_t max) | |
circular_buffer_queue () | |
~circular_buffer_queue ()=default | |
bool | de_queue (Element_type *item) |
Content of the being dequeued item is copied to the arg-pointer location. More... | |
bool | de_tail (Element_type *item) |
Similar to de_queue but extracting happens from the tail side. More... | |
size_t | en_queue (Element_type *item) |
return the index where the arg item locates or an error encoded as a value circular_buffer_queue::error_result . More... | |
Element_type * | head_queue () |
return the value of data member of the head of the queue. More... | |
bool | in (size_t i) |
size_t | get_length () const |
bool | empty () const |
bool | full () const |
Public Attributes | |
Prealloced_array< Element_type, 1 > | m_Q |
size_t | capacity |
The capacity and maximum length of the queue in terms of element. More... | |
size_t | avail |
Its value modulo capacity is index of the element where the next element will be enqueued. More... | |
size_t | entry |
The head index of the queue. More... | |
std::atomic< size_t > | len |
Actual length. More... | |
bool | inited_queue |
Static Public Attributes | |
static constexpr size_t | error_result = std::numeric_limits<size_t>::max() |
The class defines a type of queue with a predefined max capacity that is implemented using the circular memory buffer.
That is items of the queue are accessed as indexed elements of the array buffer in a way that when the index value reaches a max value it wraps around to point to the first buffer element.
|
inline |
|
inline |
|
default |
bool circular_buffer_queue< Element_type >::de_queue | ( | Element_type * | item | ) |
Content of the being dequeued item is copied to the arg-pointer location.
Dequeue from head.
[out] | item | A pointer to the being dequeued item. |
bool circular_buffer_queue< Element_type >::de_tail | ( | Element_type * | item | ) |
Similar to de_queue but extracting happens from the tail side.
[out] | item | A pointer to the being dequeued item. |
|
inline |
size_t circular_buffer_queue< Element_type >::en_queue | ( | Element_type * | item | ) |
return the index where the arg item locates or an error encoded as a value circular_buffer_queue::error_result
.
circular_buffer_queue::error_result
.
|
inline |
|
inline |
|
inline |
return the value of data
member of the head of the queue.
|
inline |
size_t circular_buffer_queue< Element_type >::avail |
Its value modulo capacity
is index of the element where the next element will be enqueued.
It's entry+length. It may be bigger than capacity, but will be smaller than 2*capacity.
size_t circular_buffer_queue< Element_type >::capacity |
The capacity and maximum length of the queue in terms of element.
size_t circular_buffer_queue< Element_type >::entry |
The head index of the queue.
It is an index of next element that will be dequeued. It is less than capacity, so it is an actual index (in contrast to avail
), don't need to be calculated modulo capacity
.
|
staticconstexpr |
bool circular_buffer_queue< Element_type >::inited_queue |
std::atomic<size_t> circular_buffer_queue< Element_type >::len |
Actual length.
It can be read while not protected by any mutex.
Prealloced_array<Element_type, 1> circular_buffer_queue< Element_type >::m_Q |