1
#pragma once
2

            
3
namespace Envoy {
4

            
5
/**
6
 * ConstSingleton allows easy global cross-thread access to a const object.
7
 *
8
 * This singleton should be used for data which is initialized once at
9
 * start-up and then be treated as immutable const data thereafter.
10
 */
11
template <class T> class ConstSingleton {
12
public:
13
  /**
14
   * Obtain an instance of the singleton for class T.
15
   * @return const T& a reference to the singleton for class T.
16
   */
17
37054869
  static const T& get() {
18
37054869
    static T* instance = new T();
19
37054869
    return *instance;
20
37054869
  }
21
};
22

            
23
} // namespace Envoy