MySQL 8.4.2
Source Code Documentation
Wait_ticket< K > Class Template Reference

Ticket register/wait auxiliary class. More...

#include <plugin_utils.h>

Public Member Functions

 Wait_ticket ()
 
virtual ~Wait_ticket ()
 
void clear ()
 
bool empty ()
 Check if there are waiting tickets. More...
 
int registerTicket (const K &key)
 Register ticker with status ongoing. More...
 
int waitTicket (const K &key, ulong timeout=0)
 Wait until ticket status is done. More...
 
int releaseTicket (const K &key, bool release_due_to_error=false)
 Set ticket status to done. More...
 
void get_all_waiting_keys (std::vector< K > &key_list)
 Gets all the waiting keys. More...
 
void set_blocked_status (bool blocked_flag)
 Blocks or unblocks the class from receiving waiting requests. More...
 
int block_until_empty (int timeout)
 

Private Attributes

mysql_mutex_t lock
 
mysql_cond_t cond
 
std::map< K, CountDownLatch * > map
 
bool blocked
 
bool waiting
 

Detailed Description

template<typename K>
class Wait_ticket< K >

Ticket register/wait auxiliary class.

Usage: registerTicket(k): create a ticket with key k with status ongoing. releaseTicket(k): set ticket with key k status to done. waitTicket(k): wait until ticket with key k status is changed to done.

Constructor & Destructor Documentation

◆ Wait_ticket()

template<typename K >
Wait_ticket< K >::Wait_ticket ( )
inline

◆ ~Wait_ticket()

template<typename K >
virtual Wait_ticket< K >::~Wait_ticket ( )
inlinevirtual

Member Function Documentation

◆ block_until_empty()

template<typename K >
int Wait_ticket< K >::block_until_empty ( int  timeout)
inline

◆ clear()

template<typename K >
void Wait_ticket< K >::clear ( )
inline

◆ empty()

template<typename K >
bool Wait_ticket< K >::empty ( )
inline

Check if there are waiting tickets.

Return values
trueempty
falseotherwise

◆ get_all_waiting_keys()

template<typename K >
void Wait_ticket< K >::get_all_waiting_keys ( std::vector< K > &  key_list)
inline

Gets all the waiting keys.

Parameters
[out]key_listall the keys to return

◆ registerTicket()

template<typename K >
int Wait_ticket< K >::registerTicket ( const K &  key)
inline

Register ticker with status ongoing.

Parameters
keyThe key that identifies the ticket
Return values
0success
!=0key already exists, error on insert or it is blocked

◆ releaseTicket()

template<typename K >
int Wait_ticket< K >::releaseTicket ( const K &  key,
bool  release_due_to_error = false 
)
inline

Set ticket status to done.

Parameters
keyThe key that identifies the ticket
release_due_to_errorInform the thread waiting that the release is due to a error
Return values
0success
!=0(key doesn't exist)

◆ set_blocked_status()

template<typename K >
void Wait_ticket< K >::set_blocked_status ( bool  blocked_flag)
inline

Blocks or unblocks the class from receiving waiting requests.

Parameters
[in]blocked_flagif the class should block or not

◆ waitTicket()

template<typename K >
int Wait_ticket< K >::waitTicket ( const K &  key,
ulong  timeout = 0 
)
inline

Wait until ticket status is done.

Note
The ticket is removed after the wait.
Parameters
keyThe key that identifies the ticket
timeoutmaximum time in seconds to wait by default is 0, which means no timeout
Return values
0success
!=0key doesn't exist, or the Ticket is blocked

Member Data Documentation

◆ blocked

template<typename K >
bool Wait_ticket< K >::blocked
private

◆ cond

template<typename K >
mysql_cond_t Wait_ticket< K >::cond
private

◆ lock

template<typename K >
mysql_mutex_t Wait_ticket< K >::lock
private

◆ map

template<typename K >
std::map<K, CountDownLatch *> Wait_ticket< K >::map
private

◆ waiting

template<typename K >
bool Wait_ticket< K >::waiting
private

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