| 35 | |
| 36 | template<typename... Args> |
| 37 | static T *Instance(Args &&... args) { |
| 38 | if (instance_ == nullptr) { |
| 39 | MutexLock lock(&mu_); |
| 40 | if (instance_ == nullptr) { |
| 41 | instance_.reset(new T(std::forward<Args>(args)...)); |
| 42 | } |
| 43 | } |
| 44 | return instance_.get(); |
| 45 | } |
| 46 | |
| 47 | protected: |
| 48 | SingletonBase() {} |