MySQL 8.0.40
Source Code Documentation
Abortable_synchronized_queue< T > Class Template Reference

Abortable synchronized queue extends synchronized queue allowing to abort methods waiting for elements on queue. More...

#include <plugin_utils.h>

Inheritance diagram for Abortable_synchronized_queue< T >:
[legend]

Public Member Functions

 Abortable_synchronized_queue (PSI_memory_key key)
 
 ~Abortable_synchronized_queue () override=default
 
bool push (const T &value) override
 Inserts an element in the queue. More...
 
bool pop (T *out) override
 Fetches the front of the queue and removes it. More...
 
bool pop () override
 Pops the front of the queue removing it. More...
 
bool front (T *out) override
 Fetches the front of the queue but does not remove it. More...
 
void abort (bool delete_elements)
 Remove all elements, abort current and future waits on retrieving elements from queue. More...
 
- Public Member Functions inherited from Synchronized_queue< T >
 Synchronized_queue (PSI_memory_key key)
 
 ~Synchronized_queue () override
 
bool empty () override
 Checks if the queue is empty. More...
 
size_t size () override
 Checks the queue size. More...
 
- Public Member Functions inherited from Synchronized_queue_interface< T >
virtual ~Synchronized_queue_interface ()=default
 

Private Attributes

bool m_abort
 

Additional Inherited Members

- Protected Attributes inherited from Synchronized_queue< T >
mysql_mutex_t lock
 
mysql_cond_t cond
 
std::queue< T, std::list< T, Malloc_allocator< T > > > queue
 

Detailed Description

template<typename T>
class Abortable_synchronized_queue< T >

Abortable synchronized queue extends synchronized queue allowing to abort methods waiting for elements on queue.

Constructor & Destructor Documentation

◆ Abortable_synchronized_queue()

template<typename T >
Abortable_synchronized_queue< T >::Abortable_synchronized_queue ( PSI_memory_key  key)
inline

◆ ~Abortable_synchronized_queue()

template<typename T >
Abortable_synchronized_queue< T >::~Abortable_synchronized_queue ( )
overridedefault

Member Function Documentation

◆ abort()

template<typename T >
void Abortable_synchronized_queue< T >::abort ( bool  delete_elements)
inline

Remove all elements, abort current and future waits on retrieving elements from queue.

Parameters
delete_elementsWhen true, apart from emptying the queue, it also delete each element. When false, the delete (memory release) responsibility belongs to the push() caller.

◆ front()

template<typename T >
bool Abortable_synchronized_queue< T >::front ( T *  out)
inlineoverridevirtual

Fetches the front of the queue but does not remove it.

Note
The method will block if the queue is empty until a element is pushed or abort is executed
Parameters
outThe fetched reference.
Returns
true if method was aborted, false otherwise

Reimplemented from Synchronized_queue< T >.

◆ pop() [1/2]

template<typename T >
bool Abortable_synchronized_queue< T >::pop ( )
inlineoverridevirtual

Pops the front of the queue removing it.

Note
The method will block if the queue is empty until a element is pushed or abort is executed
Returns
false, operation always succeeded

Reimplemented from Synchronized_queue< T >.

◆ pop() [2/2]

template<typename T >
bool Abortable_synchronized_queue< T >::pop ( T *  out)
inlineoverridevirtual

Fetches the front of the queue and removes it.

Note
The method will block if the queue is empty until a element is pushed or abort is executed
Parameters
outThe fetched reference.
Returns
true if method was aborted, false otherwise

Reimplemented from Synchronized_queue< T >.

◆ push()

template<typename T >
bool Abortable_synchronized_queue< T >::push ( const T &  value)
inlineoverridevirtual

Inserts an element in the queue.

Alerts any other thread lock on pop() or front()

Note
The method will not push if abort was executed.
Parameters
valueThe value to insert
Returns
false, operation always succeeded

Reimplemented from Synchronized_queue< T >.

Member Data Documentation

◆ m_abort

template<typename T >
bool Abortable_synchronized_queue< T >::m_abort
private

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