LCOV - code coverage report
Current view: top level - source/common/singleton - manager_impl.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 1 1 100.0 %
Date: 2024-01-05 06:35:25 Functions: 1 1 100.0 %

          Line data    Source code
       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             :   explicit ManagerImpl(Thread::ThreadFactory& thread_factory)
      21         850 :       : thread_factory_(thread_factory), run_tid_(thread_factory.currentThreadId()) {}
      22             : 
      23             :   // Singleton::Manager
      24             :   InstanceSharedPtr get(const std::string& name, SingletonFactoryCb cb, bool pin) override;
      25             : 
      26             : private:
      27             :   absl::node_hash_map<std::string, std::weak_ptr<Instance>> singletons_;
      28             :   std::vector<InstanceSharedPtr> pinned_singletons_;
      29             : 
      30             :   Thread::ThreadFactory& thread_factory_;
      31             :   const Thread::ThreadId run_tid_;
      32             : };
      33             : 
      34             : } // namespace Singleton
      35             : } // namespace Envoy

Generated by: LCOV version 1.15