Removed TimedWait from cEvent.
Unsupported on MacOS.
This commit is contained in:
parent
c019e8f0c5
commit
6ff49ec3a8
@ -116,50 +116,3 @@ void cEvent::Set(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cEvent::eWaitResult cEvent::Wait(int a_TimeoutMilliSec)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
DWORD res = WaitForSingleObject(m_Event, (DWORD)a_TimeoutMilliSec);
|
|
||||||
switch (res)
|
|
||||||
{
|
|
||||||
case WAIT_OBJECT_0:
|
|
||||||
{
|
|
||||||
// The semaphore was signalled
|
|
||||||
return wrSignalled;
|
|
||||||
}
|
|
||||||
case WAIT_TIMEOUT:
|
|
||||||
{
|
|
||||||
// The timeout was hit
|
|
||||||
return wrTimeout;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
LOGWARNING("cEvent: timed-waiting for the event failed: %d, GLE = %d. Continuing, but server may be unstable.", res, GetLastError());
|
|
||||||
return wrError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
timespec timeout;
|
|
||||||
timeout.tv_sec = time(NULL) + a_TimeoutMilliSec / 1000;
|
|
||||||
timeout.tv_nsec = (a_TimeoutMilliSec % 1000) * 1000000;
|
|
||||||
int res = sem_timedwait(m_Event, &timeout);
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
// The semaphore was signalled
|
|
||||||
return wrSignalled;
|
|
||||||
}
|
|
||||||
int err = errno;
|
|
||||||
if (err == ETIMEDOUT)
|
|
||||||
{
|
|
||||||
// The timeout was hit
|
|
||||||
return wrTimeout;
|
|
||||||
}
|
|
||||||
LOGWARNING("cEvent: timed-waiting for the event failed: %i, errno = %i. Continuing, but server may be unstable.", res, err);
|
|
||||||
return wrError;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,22 +19,12 @@
|
|||||||
class cEvent
|
class cEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum eWaitResult
|
|
||||||
{
|
|
||||||
wrSignalled,
|
|
||||||
wrTimeout,
|
|
||||||
wrError,
|
|
||||||
} ;
|
|
||||||
|
|
||||||
cEvent(void);
|
cEvent(void);
|
||||||
~cEvent();
|
~cEvent();
|
||||||
|
|
||||||
void Wait(void);
|
void Wait(void);
|
||||||
void Set (void);
|
void Set (void);
|
||||||
|
|
||||||
/// Waits for the semaphore with a timeout
|
|
||||||
eWaitResult Wait(int a_TimeoutMilliSec);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
Loading…
Reference in New Issue
Block a user