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