MySQL 8.4.2
Source Code Documentation
channel.h
Go to the documentation of this file.
1/* Copyright (c) 2020, 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#include <atomic>
24#include <functional>
25#include <set>
26#include <string>
27
29
30#include <unordered_map>
31#include "cache_allocator.h"
33
34namespace reference_caching {
35
37 public:
38 static channel_imp *create(service_names_set<> &service_names);
39 static bool destroy(channel_imp *channel);
40 static bool factory_init();
41 static bool factory_deinit();
43 std::string service_implementation);
46 std::string service_implementation);
48 static bool service_notification(const char **services, unsigned int count,
49 bool unload);
50
51 unsigned int version() { return m_version.load(std::memory_order_relaxed); }
52
54
56 service_names_set<std::string, std::less<std::string>> &dest_set);
57
58 bool is_alone() { return m_reference_count == 1; }
60 m_reference_count.fetch_add(1, std::memory_order_relaxed);
61 return this;
62 }
63 int unref() {
64 return m_reference_count.fetch_sub(1, std::memory_order_relaxed);
65 }
67
68 protected:
70 explicit channel_imp(service_names_set<> &service_names);
71
72 private:
74 m_version.fetch_add(1, std::memory_order_relaxed);
75 }
76 bool ignore_list_add(std::string &service_implementation);
77 bool ignore_list_clear();
78 bool ignore_list_remove(std::string &service_implementation);
79 // disable copy constructors
80 channel_imp(const channel_imp &) = delete;
81 channel_imp &operator=(const channel_imp &) = delete;
83
86 std::atomic<bool> m_has_ignore_list;
87 std::atomic<int> m_reference_count;
88 std::atomic<unsigned int> m_version;
89
91};
92
93typedef std::unordered_multimap<
94 std::string, channel_imp *, std::hash<std::string>,
95 std::equal_to<std::string>,
98
101
102} // namespace reference_caching
Component_malloc_allocator is a C++ STL memory allocator based on my_malloc/my_free.
Definition: component_malloc_allocator.h:63
Definition: cache_allocator.h:31
Definition: channel.h:36
static channel_imp * create(service_names_set<> &service_names)
Definition: channel.cc:63
static bool factory_deinit()
Definition: channel.cc:137
std::atomic< bool > m_has_ignore_list
Definition: channel.h:86
channel_imp()
Definition: channel.cc:52
channel_imp * ref()
Definition: channel.h:59
static bool destroy(channel_imp *channel)
Definition: channel.cc:84
static bool ignore_list_add(channel_imp *channel, std::string service_implementation)
Definition: channel.cc:204
void ignore_list_copy(service_names_set< std::string, std::less< std::string > > &dest_set)
Definition: channel.cc:182
mysql_rwlock_t m_lock
Definition: channel.h:90
static bool ignore_list_remove(channel_imp *channel, std::string service_implementation)
Definition: channel.cc:226
~channel_imp()
Definition: channel.cc:61
service_names_set & get_service_names()
Definition: channel.cc:189
channel_imp & operator=(const channel_imp &)=delete
service_names_set< std::string, std::less< std::string > > m_ignore_list
Definition: channel.h:85
void increment_version_no_lock()
Definition: channel.h:73
static bool factory_init()
Definition: channel.cc:119
std::atomic< unsigned int > m_version
Definition: channel.h:88
void initialize_service_counts()
Definition: channel.cc:154
channel_imp(const channel_imp &)=delete
int unref()
Definition: channel.h:63
service_names_set m_service_names
Definition: channel.h:84
bool is_alone()
Definition: channel.h:58
static void increment_version(channel_imp *channel)
Definition: channel.cc:113
static bool service_notification(const char **services, unsigned int count, bool unload)
Take actions to reference caching caches to refresh their cached service references.
Definition: channel.cc:265
bool ignore_list_clear()
Definition: channel.cc:235
std::atomic< int > m_reference_count
Definition: channel.h:87
unsigned int version()
Definition: channel.h:51
Definition: reference_cache_common.h:60
static int count
Definition: myisam_ftdump.cc:45
Definition: cache.cc:32
channel_by_name_hash_t * channel_by_name_hash
Definition: channel.cc:49
std::unordered_multimap< std::string, channel_imp *, std::hash< std::string >, std::equal_to< std::string >, Component_malloc_allocator< std::pair< const std::string, channel_imp * > > > channel_by_name_hash_t
Definition: channel.h:97
mysql_rwlock_t LOCK_channels
Definition: channel.cc:50
Definition: services.cc:40
Definition: task.h:427
An instrumented rwlock structure.
Definition: mysql_rwlock_bits.h:51