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
50854
  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