MySQL 8.0.39
Source Code Documentation
my_xp_cond.h
Go to the documentation of this file.
1/* Copyright (c) 2015, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef MY_XP_COND_INCLUDED
25#define MY_XP_COND_INCLUDED
26
30
31/**
32 @class My_xp_cond
33
34 Abstract class used to wrap condition for various implementations.
35
36 A typical use case of cond is:
37
38 @code{.cpp}
39
40 My_xp_cond *cond= new My_xp_cond_impl();
41 cond->init(cond_PSI_key);
42
43 cond->signal();
44
45 @endcode
46*/
48 public:
49 /**
50 Initialize cond.
51
52 @param key cond instrumentation key
53
54 @return success status
55 */
56
57 virtual int init(PSI_cond_key key) = 0;
58
59 /**
60 Destroy cond.
61
62 @return success status
63 */
64
65 virtual int destroy() = 0;
66
67 /**
68 Wait for cond to be signaled during some time before unlocking mutex.
69
70 @param mutex mutex to unlock
71 @param abstime time to wait
72 @return success status
73 */
74
75 virtual int timed_wait(mysql_mutex_t *mutex,
76 const struct timespec *abstime) = 0;
77
78 /**
79 Wait for cond to be signaled to unlock mutex.
80
81 @param mutex mutex to unlock
82 @return success status
83 */
84
85 virtual int wait(mysql_mutex_t *mutex) = 0;
86
87 /**
88 Signal cond.
89
90 @return success status
91 */
92
93 virtual int signal() = 0;
94
95 /**
96 Broadcast cond.
97
98 @return success status
99 */
100
101 virtual int broadcast() = 0;
102
103 /**
104 Get reference to native cond.
105
106 @return native cond
107 */
108
110
111 virtual ~My_xp_cond() = default;
112};
113
114#ifndef XCOM_STANDALONE
116 public:
117 explicit My_xp_cond_server();
118 ~My_xp_cond_server() override;
119
120 int init(PSI_cond_key key) override;
121 int destroy() override;
122 int timed_wait(mysql_mutex_t *mutex, const struct timespec *abstime) override;
123 int wait(mysql_mutex_t *mutex) override;
124 int signal() override;
125 int broadcast() override;
126 mysql_cond_t *get_native_cond() override;
127
128 protected:
130};
131#endif
132
133#ifndef XCOM_STANDALONE
135#endif
136{
137 public:
138 explicit My_xp_cond_impl() = default;
139 ~My_xp_cond_impl() override = default;
140};
141
142#endif // MY_XP_COND_INCLUDED
Definition: my_xp_cond.h:136
My_xp_cond_impl()=default
~My_xp_cond_impl() override=default
Definition: my_xp_cond.h:115
My_xp_cond_server()
Definition: my_xp_cond.cc:27
int broadcast() override
Broadcast cond.
Definition: my_xp_cond.cc:49
int wait(mysql_mutex_t *mutex) override
Wait for cond to be signaled to unlock mutex.
Definition: my_xp_cond.cc:43
mysql_cond_t * m_cond
Definition: my_xp_cond.h:129
int init(PSI_cond_key key) override
Initialize cond.
Definition: my_xp_cond.cc:32
int signal() override
Signal cond.
Definition: my_xp_cond.cc:47
~My_xp_cond_server() override
Definition: my_xp_cond.cc:30
mysql_cond_t * get_native_cond() override
Get reference to native cond.
Definition: my_xp_cond.cc:51
int timed_wait(mysql_mutex_t *mutex, const struct timespec *abstime) override
Wait for cond to be signaled during some time before unlocking mutex.
Definition: my_xp_cond.cc:38
int destroy() override
Destroy cond.
Definition: my_xp_cond.cc:36
Abstract class used to wrap condition for various implementations.
Definition: my_xp_cond.h:47
virtual ~My_xp_cond()=default
virtual int wait(mysql_mutex_t *mutex)=0
Wait for cond to be signaled to unlock mutex.
virtual int init(PSI_cond_key key)=0
Initialize cond.
virtual int timed_wait(mysql_mutex_t *mutex, const struct timespec *abstime)=0
Wait for cond to be signaled during some time before unlocking mutex.
virtual int destroy()=0
Destroy cond.
virtual int broadcast()=0
Broadcast cond.
virtual mysql_cond_t * get_native_cond()=0
Get reference to native cond.
virtual int signal()=0
Signal cond.
unsigned int PSI_cond_key
Instrumented cond key.
Definition: psi_cond_bits.h:44
Instrumentation helpers for conditions.
required string key
Definition: replication_asynchronous_connection_failover.proto:60
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50