MySQL 8.3.0
Source Code Documentation
reference_cache_common.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
23#ifndef REFERENCE_CACHE_COMMON_H
24#define REFERENCE_CACHE_COMMON_H
25
26#include <atomic>
27#include <set>
28#include <string>
29
30namespace reference_caching {
31
33#define PSI_category "refcache"
34
36 explicit Service_name_entry(const char *name, unsigned int count)
37 : name_{name}, count_{count} {}
39 : Service_name_entry(src.name_.c_str(), src.count_.load()) {}
41 name_ = rhs.name_;
42 count_ = rhs.count_.load();
43 return *this;
44 }
45 std::string name_;
46 mutable std::atomic<unsigned int> count_{0};
47};
48
51 const Service_name_entry &rhs) const {
52 return lhs.name_ < rhs.name_;
53 }
54};
55
56template <class Key = Service_name_entry,
57 class Less = Compare_service_name_entry>
59 : public std::set<Key, Less, Component_malloc_allocator<Key>> {
60 public:
64};
65
66} // namespace reference_caching
67
68#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:62
Definition: reference_cache_common.h:59
service_names_set()
Definition: reference_cache_common.h:61
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:48
static int count
Definition: myisam_ftdump.cc:44
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:307
std::string_view Key
The key type for the hash structure in HashJoinRowBuffer.
Definition: hash_join_buffer.h:102
Definition: cache.cc:31
PSI_memory_key KEY_mem_reference_cache
Definition: component.cc:176
Definition: varlen_sort.h:174
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2881
case opt name
Definition: sslopt-case.h:32
Definition: reference_cache_common.h:49
bool operator()(const Service_name_entry &lhs, const Service_name_entry &rhs) const
Definition: reference_cache_common.h:50
Definition: reference_cache_common.h:35
Service_name_entry(const Service_name_entry &src)
Definition: reference_cache_common.h:38
Service_name_entry(const char *name, unsigned int count)
Definition: reference_cache_common.h:36
std::string name_
Definition: reference_cache_common.h:45
Service_name_entry & operator=(const Service_name_entry &rhs)
Definition: reference_cache_common.h:40
std::atomic< unsigned int > count_
Definition: reference_cache_common.h:46