MySQL 8.4.0
Source Code Documentation
thread_cleanup_register.h
Go to the documentation of this file.
1/* Copyright (c) 2021, 2024, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef THREAD_CLEANUP_REGISTER_H
25#define THREAD_CLEANUP_REGISTER_H
26
28
29/**
30 @ingroup group_components_services_inventory
31
32 Thread cleanup service allows a OS thread to free resources allocated
33 for specific thread, during thread exit. Component can register for
34 thread cleanup handler, for desired OS threads.
35
36 At thread exit, the service 'thread_cleanup_handler' implemented
37 by the component is invoked by MySQL server.
38
39 @section Registering thread cleanup.
40
41 The service can be instantiated using the registry service with the
42 "thread_cleanup_register" name.
43
44 @code
45 SERVICE_TYPE(registry) *registry = mysql_plugin_registry_acquire();
46 my_service<SERVICE_TYPE(thread_cleanup_register)>
47 svc("thread_cleanup_register", registry);
48 if (svc.is_valid()) {
49 // The service is ready to be used
50 }
51 @endcode
52
53 The code below demonstrates way to register thread cleanup for a thread
54 from a component. Note that we cannot deregister thread cleanup event. In
55 case the component is uninstalled, then the thread cleanup is NO-OP.
56
57 @code
58 svc->register_cleanup("implementation_name");
59 @endcode
60*/
61BEGIN_SERVICE_DEFINITION(thread_cleanup_register)
62
63/**
64 Enable thread cleanup for calling thread.
65
66 @param [in] component_name Must be same as the implementation name
67 used for @ref thread_cleanup_handler service.
68
69 @return The function always fail and return TRUE value.
70*/
71DECLARE_BOOL_METHOD(register_cleanup, (char const *component_name));
72
73END_SERVICE_DEFINITION(thread_cleanup_register)
74
75#endif /* THREAD_CLEANUP_REGISTER_H */
#define END_SERVICE_DEFINITION(name)
A macro to end the last Service definition started with the BEGIN_SERVICE_DEFINITION macro.
Definition: service.h:91
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition: service.h:86
#define DECLARE_BOOL_METHOD(name, args)
Declares a method that returns bool as a part of the Service definition.
Definition: service.h:112