MySQL 8.0.39
Source Code Documentation
|
Base class for adding replication event observer infra-structure. More...
#include <rpl_handler.h>
Public Types | |
typedef List< Observer_info > | Observer_info_list |
typedef List_iterator< Observer_info > | Observer_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... | |
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.
|
private |
|
private |
|
explicit |
Class constructor.
key | the PFS key for instrumenting the class lock |
|
virtual |
Class destructor.
|
private |
Increases the info->plugin
reference counting and stores that reference internally.
int Delegate::add_observer | ( | void * | observer, |
st_plugin_int * | plugin | ||
) |
Adds an observer to the observer list.
observer | The observer object to be added to the list |
plugin | The plugin the observer is being loaded from |
bool Delegate::is_empty | ( | ) |
Returns whether or not there are registered observers.
bool Delegate::is_inited | ( | ) |
Returns whether or not this instance was initialized.
|
private |
Locks the active lock (OS read-write lock or shared spin-lock) according to the mode passed on as a parameter.
mode | The mode to lock in, either DELEGATE_LOCK_MODE_SHARED or DELEGATE_LOCK_MODE_EXCLUSIVE. |
Delegate::Observer_info_iterator Delegate::observer_info_iter | ( | ) |
Retrieves an iterator for the observer list.
int Delegate::read_lock | ( | ) |
Acquires this Delegate class instance lock in read/shared mode.
int Delegate::remove_observer | ( | void * | observer | ) |
Removes an observer from the observer list.
observer | The observer object to be added to the list |
int Delegate::unlock | ( | ) |
Releases this Delegate class instance lock.
void Delegate::update_lock_type | ( | ) |
Toggles the type of lock between a classical read-write lock and a shared-exclusive spin-lock.
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.
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.
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.
int Delegate::write_lock | ( | ) |
Acquires this Delegate class instance lock in write/exclusive mode.
|
private |
Flag statign whether or not this instance was initialized.
|
private |
A read/write lock to be used when not optimizing for static plugin config.
|
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.
|
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.
|
private |
The type of lock configured to be used, either a classic read-write (-1) lock or a shared-exclusive spin lock (1).
|
private |
A shared-exclusive spin lock to be used when optimizing for static plugin config.
|
private |
Memory pool to be used to allocate the observers list.
|
private |
List of registered observers.