Sandboxie/SandboxiePlus/MiscHelpers/Common/MT/ThreadLock.h

29 lines
666 B
C
Raw Normal View History

2022-11-12 09:45:35 +00:00
#pragma once
#include "../../mischelpers_global.h"
#include <QMutex>
#include <QWaitCondition>
/**********************************************************************************************
* CThreadLock
* This class allows to wait for events form a differet thread.
2022-12-07 16:32:40 +00:00
* When Lock returns successfully it is guaranteed that the other thread have issued a release.
* This works undependant of the real order Lock and Release ware called
2022-11-12 09:45:35 +00:00
*/
class MISCHELPERS_EXPORT CThreadLock
{
public:
CThreadLock();
void Reset();
bool Lock(unsigned long time = ULONG_MAX);
void Release();
protected:
QMutex m_Mutex;
QWaitCondition m_Wait;
bool m_Released;
};