Cleaner version of wait with timeout fix.

This commit is contained in:
W. Eric Norum
2008-10-16 13:38:14 +00:00
parent ab765613ec
commit 3b2bbd50e5

View File

@@ -131,25 +131,19 @@ epicsEventWaitWithTimeout(epicsEventId id, double timeOut)
{
rtems_id sid = (rtems_id)id;
rtems_status_code sc;
uint32_t wait;
rtems_interval delay;
extern double rtemsTicksPerSecond_double;
if (timeOut <= 0.0)
return epicsEventTryWait(id);
SEMSTAT(1)
if (timeOut <= 0.0) {
wait = RTEMS_NO_WAIT;
delay = 0;
}
else {
wait = RTEMS_WAIT;
delay = timeOut * rtemsTicksPerSecond_double;
if (delay == 0)
delay++;
}
sc = rtems_semaphore_obtain (sid, wait, delay);
delay = timeOut * rtemsTicksPerSecond_double;
if (delay == 0)
delay++;
sc = rtems_semaphore_obtain (sid, RTEMS_WAIT, delay);
if (sc == RTEMS_SUCCESSFUL)
return epicsEventWaitOK;
else if ((sc == RTEMS_TIMEOUT) || (sc == RTEMS_UNSATISFIED))
else if (sc == RTEMS_TIMEOUT)
return epicsEventWaitTimeout;
else
return epicsEventWaitError;