MySQL 9.1.0
Source Code Documentation
meb::Queue< T > Class Template Reference

This template class implements a queue that,. More...

Public Member Functions

void create ()
 Create the queue with essential objects. More...
 
void init (const int size)
 Initialize the ring buffer by allocating memory and initialize the indexes of the queue. More...
 
void deinit ()
 Deinitialize the ring buffer by deallocating memory and reset the indexes of the queue. More...
 
void drop ()
 Delete the queue and its essential objects. More...
 
void enqueue (const T &lb)
 
void dequeue (T &lb)
 Dequeue the log block from the queue and update the indexes in the ring buffer. More...
 
bool empty ()
 

Private Attributes

bool m_waiting_for_dequeue {false}
 Whether the producer waits for a dequeue event. More...
 
bool m_waiting_for_enqueue {false}
 Whether the consumer waits for an enqueue event. More...
 
int m_front {-1}
 Index representing the front of the ring buffer. More...
 
int m_rear {-1}
 Index representing the rear of the ring buffer. More...
 
int m_size {0}
 The total number of elements in the ring buffer. More...
 
std::unique_ptr< T[]> m_ring_buffer {}
 The buffer containing the contents of the queue. More...
 
ib_mutex_t m_mutex {}
 The queue mutex, used to lock the queue during the enqueue and dequeue operations, to ensure thread safety. More...
 
os_event_t m_dequeue_event {}
 When the queue is full, enqueue operations wait on this event. More...
 
os_event_t m_enqueue_event {}
 When the queue is empty, dequeue operatios wait on this event. More...
 

Detailed Description

template<typename T>
class meb::Queue< T >

This template class implements a queue that,.

  1. Implements a Ring Buffer. 1.1 The ring buffer can store QUEUE_SIZE_MAX elements. 1.2 Each element of the ring buffer stores log blocks of size QUEUE_BLOCK_SIZE.
  2. Blocks for more data to be enqueued if the queue is empty.
  3. Blocks for data to be dequeued if the queue is full.
  4. Is thread safe.

Member Function Documentation

◆ create()

template<typename T >
void meb::Queue< T >::create ( )
inline

Create the queue with essential objects.

◆ deinit()

template<typename T >
void meb::Queue< T >::deinit ( void  )
inline

Deinitialize the ring buffer by deallocating memory and reset the indexes of the queue.

◆ dequeue()

template<typename T >
void meb::Queue< T >::dequeue ( T &  lb)
inline

Dequeue the log block from the queue and update the indexes in the ring buffer.

Parameters
[out]lbThe log that was dequeued from the queue.

◆ drop()

template<typename T >
void meb::Queue< T >::drop ( )
inline

Delete the queue and its essential objects.

◆ empty()

template<typename T >
bool meb::Queue< T >::empty ( )
inline

◆ enqueue()

template<typename T >
void meb::Queue< T >::enqueue ( const T &  lb)
inline

◆ init()

template<typename T >
void meb::Queue< T >::init ( const int  size)
inline

Initialize the ring buffer by allocating memory and initialize the indexes of the queue.

The initialization is done in a separate method so that the ring buffer is allocated memory only when redo log archiving is started.

Parameters
[in]sizeThe size of the ring buffer.

Member Data Documentation

◆ m_dequeue_event

template<typename T >
os_event_t meb::Queue< T >::m_dequeue_event {}
private

When the queue is full, enqueue operations wait on this event.

When it is set, it indicates that a dequeue has happened and there is space in the queue.

◆ m_enqueue_event

template<typename T >
os_event_t meb::Queue< T >::m_enqueue_event {}
private

When the queue is empty, dequeue operatios wait on this event.

When it is set, it indicates that a enqueue operation has happened and there is an element in the queue, that can be dequeued.

◆ m_front

template<typename T >
int meb::Queue< T >::m_front {-1}
private

Index representing the front of the ring buffer.

◆ m_mutex

template<typename T >
ib_mutex_t meb::Queue< T >::m_mutex {}
private

The queue mutex, used to lock the queue during the enqueue and dequeue operations, to ensure thread safety.

◆ m_rear

template<typename T >
int meb::Queue< T >::m_rear {-1}
private

Index representing the rear of the ring buffer.

◆ m_ring_buffer

template<typename T >
std::unique_ptr<T[]> meb::Queue< T >::m_ring_buffer {}
private

The buffer containing the contents of the queue.

◆ m_size

template<typename T >
int meb::Queue< T >::m_size {0}
private

The total number of elements in the ring buffer.

◆ m_waiting_for_dequeue

template<typename T >
bool meb::Queue< T >::m_waiting_for_dequeue {false}
private

Whether the producer waits for a dequeue event.

◆ m_waiting_for_enqueue

template<typename T >
bool meb::Queue< T >::m_waiting_for_enqueue {false}
private

Whether the consumer waits for an enqueue event.


The documentation for this class was generated from the following file: