Здравствуйте, Аноним, Вы писали:
А> Как можно защитится от этого ?
template <typename T> class Singletone
{
static T * m_instance;
static SIMPLE_MUTEX m_mutex;
static void CreateInstance()
{
SIMPLE_MUTEX::lockT lock_(m_mutex);
static T loc_instance;
m_instance = &loc_instance;
}
public:
static T * Instance()
{
if (!m_instance)
CreateInstance();
return m_instance;
};
}; // class Singletone<T>
template <typename T> T * Singletone<T>::m_instance = NULL;
template <typename T> SIMPLE_MUTEX Singletone<T>::m_mutex;