MySQL 8.3.0
Source Code Documentation
thread_cleanup_register.h
Go to the documentation of this file.
1/* Copyright (c) 2021, 2023, 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 also distributed 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 included with MySQL.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License, version 2.0, for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef THREAD_CLEANUP_REGISTER_H
24#define THREAD_CLEANUP_REGISTER_H
25
27
28/**
29 @ingroup group_components_services_inventory
30
31 Thread cleanup service allows a OS thread to free resources allocated
32 for specific thread, during thread exit. Component can register for
33 thread cleanup handler, for desired OS threads.
34
35 At thread exit, the service 'thread_cleanup_handler' implemented
36 by the component is invoked by MySQL server.
37
38 @section Registering thread cleanup.
39
40 The service can be instantiated using the registry service with the
41 "thread_cleanup_register" name.
42
43 @code
44 SERVICE_TYPE(registry) *registry = mysql_plugin_registry_acquire();
45 my_service<SERVICE_TYPE(thread_cleanup_register)>
46 svc("thread_cleanup_register", registry);
47 if (svc.is_valid()) {
48 // The service is ready to be used
49 }
50 @endcode
51
52 The code below demonstrates way to register thread cleanup for a thread
53 from a component. Note that we cannot deregister thread cleanup event. In
54 case the component is uninstalled, then the thread cleanup is NO-OP.
55
56 @code
57 svc->register_cleanup("implementation_name");
58 @endcode
59*/
60BEGIN_SERVICE_DEFINITION(thread_cleanup_register)
61
62/**
63 Enable thread cleanup for calling thread.
64
65 @param [in] component_name Must be same as the implementation name
66 used for @ref thread_cleanup_handler service.
67
68 @return The function always fail and return TRUE value.
69*/
70DECLARE_BOOL_METHOD(register_cleanup, (char const *component_name));
71
72END_SERVICE_DEFINITION(thread_cleanup_register)
73
74#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:90
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition: service.h:85
#define DECLARE_BOOL_METHOD(name, args)
Declares a method that returns bool as a part of the Service definition.
Definition: service.h:111