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

#include <mutex>
#include <atomic>

using namespace std;

class MemBarrierSingleton11
{
private:
    static atomic<MemBarrierSingleton11*> instance;
    mutex mymutex;
    long long counter;
    MemBarrierSingleton11() { }
public:
    MemBarrierSingleton11(const MemBarrierSingleton11& original) = delete;
    MemBarrierSingleton11& operator=(const MemBarrierSingleton11& original) = delete;
    static MemBarrierSingleton11& Instance();
    void Reset();
    void Increment();
    long long GetCounter();
};

#endif
