1 class Singleton
2 {
3 private:
4 static Singleton* volatile instance_;
5 static ACE_Recursive_Thread_Mutex lock_;
6 protected:
7 Singleton() {}
8 public:
9 static Singleton* Instance()
10 {
11 if (instance_ == 0)
12 {
13 ACE_Guard<ACE_Recursive_Thread_Mutex> guard(lock_);
14 if (instance_ == 0)
15 instance_ = new Singleton;
16 }
17 return instance_;
18 }
19
20 };
21
22 Singleton* volatile Singleton::instance_ = 0;


相关文章:

  • 2021-08-27
  • 2022-01-25
  • 2021-08-02
  • 2021-06-09
  • 2022-02-26
  • 2022-03-12
猜你喜欢
  • 2022-12-23
  • 2021-12-01
  • 2022-01-14
  • 2021-07-21
  • 2021-05-18
  • 2021-06-28
相关资源
相似解决方案