MySQL 9.1.0
Source Code Documentation
Delegate Class Reference

Base class for adding replication event observer infra-structure. More...

#include <rpl_handler.h>

Inheritance diagram for Delegate:
[legend]

Public Types

typedef List< Observer_infoObserver_info_list
 
typedef List_iterator< Observer_infoObserver_info_iterator
 

Public Member Functions

 Delegate (PSI_rwlock_key key)
 Class constructor. More...
 
virtual ~Delegate ()
 Class destructor. More...
 
int add_observer (void *observer, st_plugin_int *plugin)
 Adds an observer to the observer list. More...
 
int remove_observer (void *observer)
 Removes an observer from the observer list. More...
 
Observer_info_iterator observer_info_iter ()
 Retrieves an iterator for the observer list. More...
 
bool is_empty ()
 Returns whether or not there are registered observers. More...
 
int read_lock ()
 Acquires this Delegate class instance lock in read/shared mode. More...
 
int write_lock ()
 Acquires this Delegate class instance lock in write/exclusive mode. More...
 
int unlock ()
 Releases this Delegate class instance lock. More...
 
bool is_inited ()
 Returns whether or not this instance was initialized. More...
 
void update_lock_type ()
 Toggles the type of lock between a classical read-write lock and a shared-exclusive spin-lock. More...
 
void update_plugin_ref_count ()
 Increases the info->plugin usage reference counting if replication_optimize_for_static_plugin_config is being enabled, in order to prevent plugin removal. More...
 
bool use_rw_lock_type ()
 Returns whether or not to use the classic read-write lock. More...
 
bool use_spin_lock_type ()
 Returns whether or not to use the shared spin-lock. More...
 

Private Types

enum  enum_delegate_lock_type { DELEGATE_OS_LOCK = -1 , DELEGATE_SPIN_LOCK = 1 }
 
enum  enum_delegate_lock_mode { DELEGATE_LOCK_MODE_SHARED = 0 , DELEGATE_LOCK_MODE_EXCLUSIVE = 1 }
 

Private Member Functions

void acquire_plugin_ref_count (Observer_info *info)
 Increases the info->plugin reference counting and stores that reference internally. More...
 
void lock_it (enum_delegate_lock_mode mode)
 Locks the active lock (OS read-write lock or shared spin-lock) according to the mode passed on as a parameter. More...
 

Private Attributes

Observer_info_list observer_info_list
 List of registered observers. More...
 
mysql_rwlock_t lock
 A read/write lock to be used when not optimizing for static plugin config. More...
 
lock::Shared_spin_lock m_spin_lock
 A shared-exclusive spin lock to be used when optimizing for static plugin config. More...
 
MEM_ROOT memroot {key_memory_delegate, 1024}
 Memory pool to be used to allocate the observers list. More...
 
bool inited
 Flag statign whether or not this instance was initialized. More...
 
std::atomic< int > m_configured_lock_type
 The type of lock configured to be used, either a classic read-write (-1) lock or a shared-exclusive spin lock (1). More...
 
std::atomic< int > m_acquired_locks
 The count of locks acquired: -1 will be added for each classic read-write lock acquisitions; +1 will be added for each shared-exclusive spin lock acquisition. More...
 
std::map< plugin_ref, size_t > m_acquired_references
 List of acquired plugin references, to be held while replication_optimize_for_static_plugin_config option is enabled. More...
 

Detailed Description

Base class for adding replication event observer infra-structure.

It's meant to be sub-classed by classes that will provide the support for the specific event types. This class is meant just to provide basic support for managing observers and managing resource access and lock acquisition.

Member Typedef Documentation

◆ Observer_info_iterator

◆ Observer_info_list

Member Enumeration Documentation

◆ enum_delegate_lock_mode

Enumerator
DELEGATE_LOCK_MODE_SHARED 
DELEGATE_LOCK_MODE_EXCLUSIVE 

◆ enum_delegate_lock_type

Enumerator
DELEGATE_OS_LOCK 
DELEGATE_SPIN_LOCK 

Constructor & Destructor Documentation

◆ Delegate()

Delegate::Delegate ( PSI_rwlock_key  key)
explicit

Class constructor.

Parameters
keythe PFS key for instrumenting the class lock

◆ ~Delegate()

Delegate::~Delegate ( )
virtual

Class destructor.

Member Function Documentation

◆ acquire_plugin_ref_count()

void Delegate::acquire_plugin_ref_count ( Observer_info info)
private

Increases the info->plugin reference counting and stores that reference internally.

◆ add_observer()

int Delegate::add_observer ( void *  observer,
st_plugin_int plugin 
)

Adds an observer to the observer list.

Parameters
observerThe observer object to be added to the list
pluginThe plugin the observer is being loaded from
Returns
0 upon success, 1 otherwise

◆ is_empty()

bool Delegate::is_empty ( )

Returns whether or not there are registered observers.

Returns
whether or not there are registered observers

◆ is_inited()

bool Delegate::is_inited ( )

Returns whether or not this instance was initialized.

Returns
whether or not this instance was initialized

◆ lock_it()

void Delegate::lock_it ( enum_delegate_lock_mode  mode)
private

Locks the active lock (OS read-write lock or shared spin-lock) according to the mode passed on as a parameter.

Parameters
modeThe mode to lock in, either DELEGATE_LOCK_MODE_SHARED or DELEGATE_LOCK_MODE_EXCLUSIVE.

◆ observer_info_iter()

Delegate::Observer_info_iterator Delegate::observer_info_iter ( )

Retrieves an iterator for the observer list.

Returns
the iterator for the observer list

◆ read_lock()

int Delegate::read_lock ( )

Acquires this Delegate class instance lock in read/shared mode.

Returns
0 upon success, 1 otherwise

◆ remove_observer()

int Delegate::remove_observer ( void *  observer)

Removes an observer from the observer list.

Parameters
observerThe observer object to be added to the list
Returns
0 upon success, 1 otherwise

◆ unlock()

int Delegate::unlock ( )

Releases this Delegate class instance lock.

Returns
0 upon success, 1 otherwise

◆ update_lock_type()

void Delegate::update_lock_type ( )

Toggles the type of lock between a classical read-write lock and a shared-exclusive spin-lock.

◆ update_plugin_ref_count()

void Delegate::update_plugin_ref_count ( )

Increases the info->plugin usage reference counting if replication_optimize_for_static_plugin_config is being enabled, in order to prevent plugin removal.

Decreases the info->plugin usage reference counting if replication_optimize_for_static_plugin_config is being disabled, in order to allow plugin removal.

◆ use_rw_lock_type()

bool Delegate::use_rw_lock_type ( )

Returns whether or not to use the classic read-write lock.

The read-write lock should be used if that type of lock is already acquired by some thread or if the server is not optimized for static plugin configuration.

Returns
true if one should use the classic read-write lock, false otherwise

◆ use_spin_lock_type()

bool Delegate::use_spin_lock_type ( )

Returns whether or not to use the shared spin-lock.

The shared spin-lock should be used if that type of lock is already acquired by some thread or if the server is optimized for static plugin configuration.

Returns
true if one should use the shared spin-lock, false otherwise

◆ write_lock()

int Delegate::write_lock ( )

Acquires this Delegate class instance lock in write/exclusive mode.

Returns
0 upon success, 1 otherwise

Member Data Documentation

◆ inited

bool Delegate::inited
private

Flag statign whether or not this instance was initialized.

◆ lock

mysql_rwlock_t Delegate::lock
private

A read/write lock to be used when not optimizing for static plugin config.

◆ m_acquired_locks

std::atomic<int> Delegate::m_acquired_locks
private

The count of locks acquired: -1 will be added for each classic read-write lock acquisitions; +1 will be added for each shared-exclusive spin lock acquisition.

◆ m_acquired_references

std::map<plugin_ref, size_t> Delegate::m_acquired_references
private

List of acquired plugin references, to be held while replication_optimize_for_static_plugin_config option is enabled.

If the option is disabled, the references in this list will be released.

◆ m_configured_lock_type

std::atomic<int> Delegate::m_configured_lock_type
private

The type of lock configured to be used, either a classic read-write (-1) lock or a shared-exclusive spin lock (1).

◆ m_spin_lock

lock::Shared_spin_lock Delegate::m_spin_lock
private

A shared-exclusive spin lock to be used when optimizing for static plugin config.

◆ memroot

MEM_ROOT Delegate::memroot {key_memory_delegate, 1024}
private

Memory pool to be used to allocate the observers list.

◆ observer_info_list

Observer_info_list Delegate::observer_info_list
private

List of registered observers.


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