/* Collection of code snippets by Arne Vajhøj */
/* (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) */
#ifndef DOUBLELOCK_SINGLETON_H
#define DOUBLELOCK_SINGLETON_H

#include <iostream>

using namespace std;


// **** double lock singleton pattern is not thread safe - never use it ****
class DoubleLockSingleton
{
private:
    static DoubleLockSingleton* instance;
    int SomeState;
    DoubleLockSingleton() { SomeState = 123; }
    DoubleLockSingleton(const DoubleLockSingleton& original) { };
    DoubleLockSingleton& operator=(const DoubleLockSingleton& original) { return *this; };
public:
    static DoubleLockSingleton* Instance();
    void SomeMethod() { cout << SomeState << endl; }
};

#endif
