version 1.12, 2008/06/18 18:12:00
|
version 1.13, 2008/08/13 19:40:59
|
|
|
| |
// block until this semaphore is in a signalled state or | // block until this semaphore is in a signalled state or |
// throw an exception if the wait fails | // throw an exception if the wait fails |
void Semaphore::wait(Boolean ignoreInterrupt) |
void Semaphore::wait() |
{ | { |
// Acquire mutex to enter critical section. | // Acquire mutex to enter critical section. |
pthread_mutex_lock(&_rep.mutex); | pthread_mutex_lock(&_rep.mutex); |
|
|
| |
// block until this semaphore is in a signalled state, or | // block until this semaphore is in a signalled state, or |
// throw an exception if the wait fails | // throw an exception if the wait fails |
void Semaphore::wait(Boolean ignoreInterrupt) |
void Semaphore::wait() |
{ | { |
do | do |
{ | { |
|
|
if (rc == 0) | if (rc == 0) |
break; | break; |
| |
int e = errno; |
if (errno != EINTR) |
if (e == EINTR) |
|
{ | { |
if (ignoreInterrupt == false) |
throw WaitFailed(_rep.owner); |
{ |
|
throw(WaitInterrupted(_rep.owner)); |
|
} |
|
} |
|
else |
|
{ |
|
throw(WaitFailed(_rep.owner)); |
|
} | } |
| |
// keep going if above conditions fail | // keep going if above conditions fail |
|
|
} | } |
| |
// block until this semaphore is in a signalled state | // block until this semaphore is in a signalled state |
// note that windows does not support interrupt |
void Semaphore::wait() |
void Semaphore::wait(Boolean ignoreInterrupt) |
|
{ | { |
DWORD errorcode = WaitForSingleObject(_rep.sem, INFINITE); | DWORD errorcode = WaitForSingleObject(_rep.sem, INFINITE); |
if (errorcode != WAIT_FAILED) | if (errorcode != WAIT_FAILED) |
|
|
} | } |
else | else |
{ | { |
throw(WaitFailed(Threads::self())); |
throw WaitFailed(Threads::self()); |
} | } |
} | } |
| |