MySQL 8.4.0
Source Code Documentation
locking_service.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 LOCKING_SERVICE_INCLUDED
25#define LOCKING_SERVICE_INCLUDED
26
27#include <stddef.h>
28
29#include "my_systime.h" // Timout_type
30#include "mysql/service_locking.h" // enum_locking_service_lock_type
31class THD;
32
33/**
34 Acquire locking service locks.
35
36 @param opaque_thd Thread handle. If NULL, current_thd will be used.
37 @param lock_namespace Namespace of the locks to acquire.
38 @param lock_names Array of names of the locks to acquire.
39 @param lock_num Number of elements in 'lock_names'.
40 @param lock_type Lock type to acquire. LOCKING_SERVICE_READ or _WRITE.
41 @param lock_timeout Number of seconds to wait before giving up.
42
43 @retval 1 Acquisition failed, error has been reported.
44 @retval 0 Acquisition successful, all locks acquired.
45
46 @note both lock_namespace and lock_names are limited to 64 characters max.
47 Names are compared using binary comparison.
48*/
50 const char *lock_namespace,
51 const char **lock_names, size_t lock_num,
52 enum enum_locking_service_lock_type lock_type,
53 Timeout_type lock_timeout);
54
55/**
56 Release all lock service locks taken by the given connection
57 in the given namespace.
58
59 @param opaque_thd Thread handle. If NULL, current_thd will be used.
60 @param lock_namespace Namespace of the locks to release.
61
62 @retval 1 Release failed, error has been reported.
63 @retval 0 Release successful, all locks acquired.
64*/
66 const char *lock_namespace);
67
68/**
69 Release all locking service locks taken by the given connection
70 in all namespaces.
71
72 @param thd Thread handle.
73*/
75
76#endif /* LOCKING_SERVICE_INCLUDED */
#define MYSQL_THD
Definition: backup_page_tracker.h:38
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
void release_all_locking_service_locks(THD *thd)
Release all locking service locks taken by the given connection in all namespaces.
Definition: locking_service.cc:167
int acquire_locking_service_locks(MYSQL_THD opaque_thd, const char *lock_namespace, const char **lock_names, size_t lock_num, enum enum_locking_service_lock_type lock_type, Timeout_type lock_timeout)
Acquire locking service locks.
Definition: locking_service.cc:110
int release_locking_service_locks(MYSQL_THD opaque_thd, const char *lock_namespace)
Release all lock service locks taken by the given connection in the given namespace.
Definition: locking_service.cc:150
Defines for getting and processing the current system type programmatically.
std::uint64_t Timeout_type
Type alias to reduce chance of conversion errors on timeout values.
Definition: my_systime.h:125
Implements mysql_locking_service_st.
enum_locking_service_lock_type
Types of locking service locks.
Definition: service_locking.h:52