MySQL 8.3.0
Source Code Documentation
mysql_client_thread_token.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018, 2023, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is also distributed with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have included with MySQL.
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 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
25#ifndef ROUTER_MYSQL_CLIENT_THREAD_TOKEN_INCLUDED
26#define ROUTER_MYSQL_CLIENT_THREAD_TOKEN_INCLUDED
27
28#include <stdexcept>
29
30#include <mysql.h>
31
32namespace mysqlrouter {
33
34/**
35 * Thread Token for libmysqlclient API users.
36 *
37 * libmysqlclient requires that all threads that used the API deinit
38 * via mysql_thread_end()
39 *
40 * @note Not calling mysql_thread_end() for a thread which had
41 * mysql_thread_init() called leads to 5 seconds wait on mysql_library_end()
42 * in debug-builds.
43 *
44 * While the first call to to mysql_init() in a thread calls,
45 * mysql_thread_init() automatically, there is no equivalent for the shutdown.
46 *
47 * Placing the thread token on the stack ensures right after the
48 * thread is started ensures, the thread is properly accounted for
49 * by libmysqlclient.
50 *
51 * @code
52 * void *some_thread(void *) {
53 * MySQLClientThreadToken api_token;
54 *
55 * if (true) throw std::runtime_error();
56 *
57 * return nullptr;
58 * }
59 * @endcode
60 *
61 * @see mysql_library_end()
62 * @see mysql_thread_end()
63 * @see my_thread_end()
64 */
66 public:
68
70
71 private:
72 // disable copy constructor
74 // disable copy assignment
76 // disable move constructor
78 // disable move assignment
80};
81
82} // namespace mysqlrouter
83#endif
Thread Token for libmysqlclient API users.
Definition: mysql_client_thread_token.h:65
~MySQLClientThreadToken()
Definition: mysql_client_thread_token.h:69
MySQLClientThreadToken & operator=(MySQLClientThreadToken &&)=delete
MySQLClientThreadToken(MySQLClientThreadToken &&)=delete
MySQLClientThreadToken & operator=(const MySQLClientThreadToken &)=delete
MySQLClientThreadToken(const MySQLClientThreadToken &)=delete
MySQLClientThreadToken()
Definition: mysql_client_thread_token.h:67
This file defines the client API to MySQL and also the ABI of the dynamically linked libmysqlclient.
bool STDCALL mysql_thread_init(void)
Definition: libmysql.cc:226
void STDCALL mysql_thread_end(void)
Definition: libmysql.cc:228
Definition: dim.h:357