summaryrefslogtreecommitdiff
path: root/include/m_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/m_utils.h')
-rw-r--r--include/m_utils.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/m_utils.h b/include/m_utils.h
index e44a3609c6..d7dc704085 100644
--- a/include/m_utils.h
+++ b/include/m_utils.h
@@ -517,6 +517,20 @@ struct MIR_APP_EXPORT MAsyncObject : public MNonCopyable
MIR_APP_DLL(void) Utils_InvokeAsync(MAsyncObject *pObj);
/////////////////////////////////////////////////////////////////////////////////////////
+
+class MEventHandle
+{
+ HANDLE _hEvent;
+public:
+ __inline explicit MEventHandle() { _hEvent = CreateEvent(NULL, 0, 0, NULL); }
+ __inline explicit MEventHandle(HANDLE hEvent) : _hEvent(hEvent) {}
+ __inline ~MEventHandle() { CloseHandle(_hEvent); }
+ __inline void Set() { SetEvent(_hEvent); }
+ __inline void Wait(uint32_t dwMilliseconds = INFINITE) { WaitForSingleObject(_hEvent, dwMilliseconds); }
+ __inline operator HANDLE() { return _hEvent; }
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
// compatibility functions
#ifndef _WINDOWS