mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Comments (before the code will be removed completely)
This commit is contained in:
parent
c67dbc515e
commit
a7ab08498c
@ -2,7 +2,15 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace ext {
|
||||
namespace ext
|
||||
{
|
||||
|
||||
/** Thread-unsafe singleton. It works simply like a global variable.
|
||||
* Supports deinitialization.
|
||||
*
|
||||
* In most of the cases, you don't need this class.
|
||||
* Use "Meyers Singleton" instead: static T & instance() { static T x; return x; }
|
||||
*/
|
||||
|
||||
template <class T>
|
||||
class Singleton
|
||||
@ -11,14 +19,7 @@ public:
|
||||
Singleton()
|
||||
{
|
||||
if (!instance)
|
||||
instance.reset(new T);
|
||||
}
|
||||
|
||||
template <typename ... Args>
|
||||
Singleton(const Args & ... args)
|
||||
{
|
||||
instance.reset(new T(args...));
|
||||
/// TODO: throw exception on double-creation.
|
||||
instance = std::make_unique<T>();
|
||||
}
|
||||
|
||||
T * operator->()
|
||||
|
Loading…
Reference in New Issue
Block a user