MySQL 9.1.0
Source Code Documentation
reference_cache_common.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
24#ifndef REFERENCE_CACHE_COMMON_H
25#define REFERENCE_CACHE_COMMON_H
26
27#include <atomic>
28#include <set>
29#include <string>
30
31namespace reference_caching {
32
34#define PSI_category "refcache"
35
37 explicit Service_name_entry(const char *name, unsigned int count)
38 : name_{name}, count_{count} {}
40 : Service_name_entry(src.name_.c_str(), src.count_.load()) {}
42 name_ = rhs.name_;
43 count_ = rhs.count_.load();
44 return *this;
45 }
46 std::string name_;
47 mutable std::atomic<unsigned int> count_{0};
48};
49
52 const Service_name_entry &rhs) const {
53 return lhs.name_ < rhs.name_;
54 }
55};
56
57template <class Key = Service_name_entry,
58 class Less = Compare_service_name_entry>
60 : public std::set<Key, Less, Component_malloc_allocator<Key>> {
61 public:
65};
66
67} // namespace reference_caching
68
69#endif /* REFERENCE_CACHE_COMMON_H */
Component_malloc_allocator is a C++ STL memory allocator based on my_malloc/my_free.
Definition: component_malloc_allocator.h:63
Definition: reference_cache_common.h:60
service_names_set()
Definition: reference_cache_common.h:62
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
static int count
Definition: myisam_ftdump.cc:45
bool load(THD *, const dd::String_type &fname, dd::String_type *buf)
Read an sdi file from disk and store in a buffer.
Definition: sdi_file.cc:308
std::string_view Key
The key type for the hash structure in HashJoinRowBuffer.
Definition: hash_join_buffer.h:108
Definition: cache.cc:32
PSI_memory_key KEY_mem_reference_cache
Definition: component.cc:177
Definition: gcs_xcom_synode.h:64
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2884
case opt name
Definition: sslopt-case.h:29
Definition: reference_cache_common.h:50
bool operator()(const Service_name_entry &lhs, const Service_name_entry &rhs) const
Definition: reference_cache_common.h:51
Definition: reference_cache_common.h:36
Service_name_entry(const Service_name_entry &src)
Definition: reference_cache_common.h:39
Service_name_entry(const char *name, unsigned int count)
Definition: reference_cache_common.h:37
std::string name_
Definition: reference_cache_common.h:46
Service_name_entry & operator=(const Service_name_entry &rhs)
Definition: reference_cache_common.h:41
std::atomic< unsigned int > count_
Definition: reference_cache_common.h:47