MySQL
9.6.0
Source Code Documentation
mysql_my_thread.h
Go to the documentation of this file.
1
/* Copyright (c) 2025, 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 MYSQL_SERVICE_MY_THREAD_H
25
#define MYSQL_SERVICE_MY_THREAD_H
26
27
#include <
mysql/components/service.h
>
28
29
/**
30
@ingroup group_components_services_inventory
31
32
A service allowing allocation thread specific memory for a calling thread.
33
34
Specific memory is used by mysys and dbug purposes. The example below shows
35
how to use the service by the std::thread that uses the
36
mysql_service_mysql_debug_keyword_service service. keyword);
37
38
@code
39
40
static void *a_thread(void *arg) {
41
// Allocate thread memory
42
mysql_service_mysql_my_thread->attach();
43
44
// Thread custom code begins here
45
if
46
(mysql_service_mysql_debug_keyword_service->lookup_debug_keyword("my_keyword"))
47
printf("my_keyword found!");
48
49
// Deallocate thread memory on thread exit.
50
mysql_service_mysql_my_thread->detach();
51
52
return nullptr;
53
}
54
55
std::thread thread(a_thread);
56
57
thread.join();
58
59
@endcode
60
*/
61
BEGIN_SERVICE_DEFINITION
(mysql_my_thread)
62
63
/*
64
Allocate thread specific memory for the thread, used by mysys and dbug.
65
66
@return Zero value on success.
67
*/
68
DECLARE_BOOL_METHOD
(attach, ());
69
70
/*
71
Deallocate thread specific memory allocated with an attach() method.
72
73
@return Zero value on success.
74
*/
75
DECLARE_BOOL_METHOD
(detach, ());
76
77
/*
78
Check, whether the attach() method was successfully called.
79
80
@return attach() result.
81
*/
82
DECLARE_BOOL_METHOD
(is_attached, ());
83
84
END_SERVICE_DEFINITION
(mysql_my_thread)
85
86
#endif
/* MYSQL_SERVICE_MY_THREAD_H */
service.h
END_SERVICE_DEFINITION
#define END_SERVICE_DEFINITION(name)
A macro to end the last Service definition started with the BEGIN_SERVICE_DEFINITION macro.
Definition:
service.h:91
BEGIN_SERVICE_DEFINITION
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition:
service.h:86
DECLARE_BOOL_METHOD
#define DECLARE_BOOL_METHOD(name, args)
Declares a method that returns bool as a part of the Service definition.
Definition:
service.h:112
include
mysql
components
services
mysql_my_thread.h
Generated by
1.9.2