6 #ifndef _INC_cSysEvent_H
7 #define _INC_cSysEvent_H
12 #include "../GrayLibBase.h"
20 struct _SECURITY_ATTRIBUTES;
37 static const ::pthread_mutex_t k_mutexInit;
38 static const ::pthread_cond_t k_condInit;
39 ::pthread_mutex_t m_mutex;
40 ::pthread_cond_t m_cond;
49 m_mutex = k_mutexInit;
51 m_bManualReset =
false;
60 ::pthread_cond_destroy(&m_cond);
61 ::pthread_mutex_destroy(&m_mutex);
67 HANDLE get_EventHandle() const noexcept
71 #elif defined(__linux__)
72 ::pthread_cond_t get_CondHandle() const noexcept
89 bool CreateEventX(_SECURITY_ATTRIBUTES* lpEventAttributes =
nullptr,
90 bool bManualReset =
false,
91 bool bInitialState =
false,
98 m_h.
AttachHandle(
_FNF(::CreateEvent)(lpEventAttributes, bManualReset, bInitialState, lpName));
100 m_mutex = k_mutexInit;
101 if (::pthread_cond_init(&m_cond,
nullptr) != 0)
105 m_bManualReset = bManualReset;
106 m_bSignaled = bInitialState;
108 return isValidEvent();
117 return isValidEvent() ;
126 return(::SetEvent(m_h) !=
false);
128 ::pthread_mutex_lock(&m_mutex);
129 m_bSignaled = m_bManualReset;
130 int iRet = ::pthread_cond_broadcast(&m_cond);
131 ::pthread_mutex_unlock(&m_mutex);
142 return(::ResetEvent(m_h) !=
false);
153 return ::PulseEvent(m_h) != false ;
155 bool bManualResetOld = m_bManualReset;
156 m_bManualReset =
false;
158 m_bManualReset = bManualResetOld;
#define _FNF(c)
_WIN32 name has a A or W for UTF8 or UNICODE
Definition: FileName.h:24
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define ASSERT(exp)
Definition: cDebugAssert.h:87
Definition: cSysEvent.h:28
UNITTEST2_PREDEF(cSysEvent)
bool CreateEventX(_SECURITY_ATTRIBUTES *lpEventAttributes=nullptr, bool bManualReset=false, bool bInitialState=false, const FILECHAR_t *lpName=nullptr)
Definition: cSysEvent.h:89
~cSysEvent()
Definition: cSysEvent.h:55
bool SetEvent()
Definition: cSysEvent.h:121
bool isValidEvent() const noexcept
Definition: cSysEvent.h:80
bool PulseEvent()
Definition: cSysEvent.h:148
bool ResetEvent()
Definition: cSysEvent.h:135
cSysEvent() noexcept
Definition: cSysEvent.h:46
Definition: cOSHandle.h:59
void AttachHandle(HANDLE h) noexcept
Definition: cOSHandle.h:163
bool isValidHandle() const noexcept
Definition: cOSHandle.h:125
UNITTEST2_PREDEF(cQuadtree)
INT32 TIMESYSD_t
Time delta. signed milli-Seconds Span. cTimeSys::k_DMAX, cTimeSys::k_INF = MAILSLOT_WAIT_FOREVER.
Definition: cTimeSys.h:28
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22