1#ifndef RPL_RESOURCE_BLOCKER_H_INCLUDED
2#define RPL_RESOURCE_BLOCKER_H_INCLUDED
91 [[nodiscard]]
int try_block(
const std::string &reason) {
103 assert(removed_count == 1);
159 *
this = std::move(other);
165 if (
this == &other) {
184 other.m_resource =
nullptr;
242 *
this = std::move(other);
248 if (
this == &other) {
269 other.m_resource =
nullptr;
271 other.m_user_count = 0;
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
Definition: resource_blocker.h:219
Blocker & operator=(Blocker const &other)
Release our own Resource, if any, and then block the same Resource that other blocks,...
Definition: resource_blocker.h:247
std::string m_reason
Definition: resource_blocker.h:300
Blocker(Blocker &&other) noexcept
Take over the Resource that other blocks, if any.
Definition: resource_blocker.h:241
Blocker()
By default, does not block any Resource.
Definition: resource_blocker.h:222
Blocker(Blocker &other)
Block the same Resource that other blocks, if any.
Definition: resource_blocker.h:236
Resource * m_resource
Definition: resource_blocker.h:299
Blocker(Resource &resource, const std::string &reason)
Attempt to start using the given Resource.
Definition: resource_blocker.h:227
void end_block()
Stop blocking the Resource, if we do.
Definition: resource_blocker.h:286
int m_user_count
Definition: resource_blocker.h:301
bool operator!()
Return false if we block the Resource.
Definition: resource_blocker.h:279
int user_count() const
Return the number of users of the Resource at the time we tried to block it.
Definition: resource_blocker.h:283
Blocker & operator=(Blocker &&other) noexcept
Release our own resource, if any, and then steal the Resource that other blocks, if any,...
Definition: resource_blocker.h:264
~Blocker()
Stop holding the Resource in 'used' state, if we do.
Definition: resource_blocker.h:296
Represents a "Resource" which can be either "used" by a number of threads, or "blocked" by a number o...
Definition: resource_blocker.h:70
Resource & operator=(Resource const &other)=delete
void end_block(const std::string &reason)
Unblock the resource if try_block was previously called successfully.
Definition: resource_blocker.h:100
mysql_mutex_t m_lock
Definition: resource_blocker.h:128
String_set try_use()
Try to start using the resource.
Definition: resource_blocker.h:107
Resource & operator=(Resource &&other)=delete
mysql_mutex_t & get_lock()
Definition: resource_blocker.h:123
~Resource()
Definition: resource_blocker.h:78
std::set< std::string > String_set
Definition: resource_blocker.h:72
int m_user_count
Definition: resource_blocker.h:126
void end_use()
Stop using the resource if try_use was previously called successfully.
Definition: resource_blocker.h:117
Resource(Resource &other)=delete
String_set m_block_reasons
Definition: resource_blocker.h:125
Resource(Resource &&other)=delete
Resource()
Definition: resource_blocker.h:74
int try_block(const std::string &reason)
Try to block the resource from being used, for the given reason.
Definition: resource_blocker.h:91
std::atomic< int > m_initialized
Definition: resource_blocker.h:127
Definition: resource_blocker.h:137
~User()
Stop holding the Resource in 'used' state, if we do.
Definition: resource_blocker.h:209
User(User &&other) noexcept
Take over the Resource that other uses, if any.
Definition: resource_blocker.h:158
void end_use()
Stop holding the Resource in 'used' state, if we do.
Definition: resource_blocker.h:199
User()
By default, does not use any Resource.
Definition: resource_blocker.h:140
User(Resource &resource)
Attempt to start using the given Resource.
Definition: resource_blocker.h:145
User & operator=(User const &other)
Release our own Resource, if any, and then start using the Resource that other uses,...
Definition: resource_blocker.h:164
bool operator!()
Return false if we hold the Resource in 'used' state.
Definition: resource_blocker.h:192
Resource * m_resource
Definition: resource_blocker.h:212
User & operator=(User &&other) noexcept
Release our own resource, if any, and then steal the Resource that other uses, if any,...
Definition: resource_blocker.h:180
Resource::String_set block_reasons()
Return the set of strings that explain the reasons why the resource was blocked.
Definition: resource_blocker.h:196
User(User &other)
Use the same Resource that other uses, if any.
Definition: resource_blocker.h:155
Resource::String_set m_block_reasons
Definition: resource_blocker.h:213
#define mysql_mutex_destroy(M)
Definition: mysql_mutex.h:46
#define mysql_mutex_init(K, M, A)
Definition: mysql_mutex.h:41
static constexpr unsigned PSI_INSTRUMENT_ME
Definition: psi_bits.h:43
#define MUTEX_LOCK(NAME, X)
Definition: mutex_lock.h:83
Definition: resource_blocker.h:32
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
#define MY_MUTEX_INIT_FAST
Definition: thr_mutex.h:68