MySQL 9.0.0
Source Code Documentation
|
Represents a "Resource" which can be either "used" by a number of threads, or "blocked" by a number of threads. More...
#include <resource_blocker.h>
Public Types | |
using | String_set = std::set< std::string > |
Public Member Functions | |
Resource () | |
~Resource () | |
Resource (Resource &other)=delete | |
Resource (Resource &&other)=delete | |
Resource & | operator= (Resource const &other)=delete |
Resource & | operator= (Resource &&other)=delete |
Private Member Functions | |
int | try_block (const std::string &reason) |
Try to block the resource from being used, for the given reason. More... | |
void | end_block (const std::string &reason) |
Unblock the resource if try_block was previously called successfully. More... | |
String_set | try_use () |
Try to start using the resource. More... | |
void | end_use () |
Stop using the resource if try_use was previously called successfully. More... | |
mysql_mutex_t & | get_lock () |
Private Attributes | |
String_set | m_block_reasons |
int | m_user_count |
std::atomic< int > | m_initialized |
mysql_mutex_t | m_lock |
Friends | |
class | User |
class | Blocker |
Represents a "Resource" which can be either "used" by a number of threads, or "blocked" by a number of threads.
When one or more threads use the resource, no thread can block it. When a one or more threads is blocking the resource, no thread can use it. Each blocker provides a message that explains why the resource is blocked.
The resource is blocked or used by creating instances of the Blocker and User classes.
using resource_blocker::Resource::String_set = std::set<std::string> |
|
inline |
|
inline |
|
delete |
|
delete |
|
inlineprivate |
Unblock the resource if try_block was previously called successfully.
|
inlineprivate |
Stop using the resource if try_use was previously called successfully.
|
inlineprivate |
|
inlineprivate |
Try to block the resource from being used, for the given reason.
|
inlineprivate |
Try to start using the resource.
|
friend |
|
friend |
|
private |
|
private |
|
mutableprivate |
|
private |