Coverage Report

Created: 2024-09-19 09:45

/proc/self/cwd/source/common/singleton/manager_impl.h
Line
Count
Source
1
#pragma once
2
3
#include "envoy/singleton/manager.h"
4
#include "envoy/thread/thread.h"
5
6
#include "source/common/common/non_copyable.h"
7
8
#include "absl/container/node_hash_map.h"
9
10
namespace Envoy {
11
namespace Singleton {
12
13
/**
14
 * Implementation of the singleton manager that checks the registry for name validity. It is
15
 * assumed the singleton manager is only used on the main thread so it is not thread safe. Asserts
16
 * verify that.
17
 */
18
class ManagerImpl : public Manager, NonCopyable {
19
public:
20
66.2k
  ManagerImpl() = default;
21
22
  // Singleton::Manager
23
  InstanceSharedPtr get(const std::string& name, SingletonFactoryCb cb, bool pin) override;
24
25
private:
26
  absl::node_hash_map<std::string, std::weak_ptr<Instance>> singletons_;
27
  std::vector<InstanceSharedPtr> pinned_singletons_;
28
};
29
30
} // namespace Singleton
31
} // namespace Envoy