MySQL  8.0.26
Source Code Documentation
guard.h
Go to the documentation of this file.
1 #ifndef INCLUDE_GUARD_H_
2 #define INCLUDE_GUARD_H_
3 /* Copyright (c) 2019, 2021, Oracle and/or its affiliates.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License, version 2.0,
7  as published by the Free Software Foundation.
8 
9  This program is also distributed with certain software (including
10  but not limited to OpenSSL) that is licensed under separate terms,
11  as designated in a particular file or component or in included license
12  documentation. The authors of MySQL hereby grant you an additional
13  permission to link the program and your derivative works with the
14  separately licensed software that they have included with MySQL.
15 
16  This program is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License, version 2.0, for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
24 
25 /**
26  @file guard.h RAII classes for locking/unlocking, inspired by the guard
27  class of Boost fame.
28 */
29 
30 #include <mysql/psi/mysql_mutex.h>
31 #include <mysql/psi/mysql_rwlock.h>
32 #include <mysql/psi/mysql_thread.h>
33 
34 /// Guards a mutex.
35 class Mutex_guard {
36  public:
37  Mutex_guard(const Mutex_guard &lock) = delete;
38 
39  /**
40  Object construction that locks specified mutex.
41 
42  @param mutex Mutex pointer to be locked.
43  */
44  explicit Mutex_guard(mysql_mutex_t *mutex) : m_mutex(mutex) {
46  }
47 
48  /// Destroys object and unlocks the mutex.
50 
51  private:
53 };
54 
55 #endif // INCLUDE_GUARD_H_
Guards a mutex.
Definition: guard.h:35
Mutex_guard(mysql_mutex_t *mutex)
Object construction that locks specified mutex.
Definition: guard.h:44
mysql_mutex_t * m_mutex
Definition: guard.h:52
Mutex_guard(const Mutex_guard &lock)=delete
~Mutex_guard()
Destroys object and unlocks the mutex.
Definition: guard.h:49
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:49
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:56
Instrumentation helpers for mysys threads.
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:78
Instrumentation helpers for mutexes.
Instrumentation helpers for rwlock.
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49