template<typename Singleton>
class CSingleton
{
private:
CSingleton();
static pthread_t mutex_;
public:
CSingleton(const Singleton&)=delete;
CSingleton& operator=(const Singleton&)=delete;
static Singleton *Getinstance()
{
if(m_Instance == NULL)
{
pthread_mutex_lock(mutex_);
if(m_Instance == NULL)
{
m_Instance = new Singleton();
}
pthread_mutex_unlock(mutex_)
}
return m_Instance;
}
static Singleton *m_Instance;
};
Singleton* CSingleton::m_Instance = 0;
template<typename Singleton>
class CSingleton
{
private:
CSingleton();
public:
CSingleton(const Singleton&)=delete;
CSingleton& operator=(const Singleton&)=delete;
static Singleton* get_instance(){
static Singleton* m_instance = new Singleton();
return instance;
}
};
template<typename Singleton>
class CSingleton {
private:
CSingleton();
static Singleton* m_instance = new Singleton();
public:
CSingleton(const Singleton&)=delete;
CSingleton& operator=(const Singleton&)=delete;
Singleton* getInstance()
{
return m_instance;
}
}