///////////////////////////////////////////////////////////////////////////////
// MuldeR's Utilities for Qt
-// Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2019 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
public:
inline CSLocker(CriticalSection &criticalSection)
:
- m_locked(false),
m_criticalSection(criticalSection)
{
m_criticalSection.enter();
- m_locked = true;
+ m_locked.ref();
}
inline ~CSLocker(void)
inline void forceUnlock(void)
{
- if(m_locked)
+ if (m_locked.fetchAndStoreOrdered(0) > 0)
{
m_criticalSection.leave();
- m_locked = false;
}
}
protected:
- volatile bool m_locked;
+ QAtomicInt m_locked;
CriticalSection &m_criticalSection;
};
}