MySQL 8.3.0
Source Code Documentation
channel.h
Go to the documentation of this file.
1/* Copyright (c) 2020, 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#include <atomic>
23#include <functional>
24#include <set>
25#include <string>
26
28
29#include <unordered_map>
30#include "cache_allocator.h"
32
33namespace reference_caching {
34
36 public:
37 static channel_imp *create(service_names_set<> &service_names);
38 static bool destroy(channel_imp *channel);
39 static bool factory_init();
40 static bool factory_deinit();
42 std::string service_implementation);
45 std::string service_implementation);
47 static bool service_notification(const char **services, unsigned int count,
48 bool unload);
49
50 unsigned int version() { return m_version.load(std::memory_order_relaxed); }
51
53
55 service_names_set<std::string, std::less<std::string>> &dest_set);
56
57 bool is_alone() { return m_reference_count == 1; }
59 m_reference_count.fetch_add(1, std::memory_order_relaxed);
60 return this;
61 }
62 int unref() {
63 return m_reference_count.fetch_sub(1, std::memory_order_relaxed);
64 }
66
67 protected:
69 explicit channel_imp(service_names_set<> &service_names);
70
71 private:
73 m_version.fetch_add(1, std::memory_order_relaxed);
74 }
75 bool ignore_list_add(std::string &service_implementation);
76 bool ignore_list_clear();
77 bool ignore_list_remove(std::string &service_implementation);
78 // disable copy constructors
79 channel_imp(const channel_imp &) = delete;
80 channel_imp &operator=(const channel_imp &) = delete;
82
85 std::atomic<bool> m_has_ignore_list;
86 std::atomic<int> m_reference_count;
87 std::atomic<unsigned int> m_version;
88
90};
91
92typedef std::unordered_multimap<
93 std::string, channel_imp *, std::hash<std::string>,
94 std::equal_to<std::string>,
97
100
101} // namespace reference_caching
Component_malloc_allocator is a C++ STL memory allocator based on my_malloc/my_free.
Definition: component_malloc_allocator.h:62
Definition: cache_allocator.h:30
Definition: channel.h:35
static channel_imp * create(service_names_set<> &service_names)
Definition: channel.cc:62
static bool factory_deinit()
Definition: channel.cc:136
std::atomic< bool > m_has_ignore_list
Definition: channel.h:85
channel_imp()
Definition: channel.cc:51
channel_imp * ref()
Definition: channel.h:58
static bool destroy(channel_imp *channel)
Definition: channel.cc:83
static bool ignore_list_add(channel_imp *channel, std::string service_implementation)
Definition: channel.cc:203
void ignore_list_copy(service_names_set< std::string, std::less< std::string > > &dest_set)
Definition: channel.cc:181
mysql_rwlock_t m_lock
Definition: channel.h:89
static bool ignore_list_remove(channel_imp *channel, std::string service_implementation)
Definition: channel.cc:225
~channel_imp()
Definition: channel.cc:60
service_names_set & get_service_names()
Definition: channel.cc:188
channel_imp & operator=(const channel_imp &)=delete
service_names_set< std::string, std::less< std::string > > m_ignore_list
Definition: channel.h:84
void increment_version_no_lock()
Definition: channel.h:72
static bool factory_init()
Definition: channel.cc:118
std::atomic< unsigned int > m_version
Definition: channel.h:87
void initialize_service_counts()
Definition: channel.cc:153
channel_imp(const channel_imp &)=delete
int unref()
Definition: channel.h:62
service_names_set m_service_names
Definition: channel.h:83
bool is_alone()
Definition: channel.h:57
static void increment_version(channel_imp *channel)
Definition: channel.cc:112
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:264
bool ignore_list_clear()
Definition: channel.cc:234
std::atomic< int > m_reference_count
Definition: channel.h:86
unsigned int version()
Definition: channel.h:50
Definition: reference_cache_common.h:59
static int count
Definition: myisam_ftdump.cc:44
Definition: cache.cc:31
channel_by_name_hash_t * channel_by_name_hash
Definition: channel.cc:48
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:96
mysql_rwlock_t LOCK_channels
Definition: channel.cc:49
Definition: services.cc:39
Definition: task.h:426
An instrumented rwlock structure.
Definition: mysql_rwlock_bits.h:50