mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
Fixes for semaphores on *nix.
This commit is contained in:
@ -284,6 +284,7 @@ hsSemaphore::hsSemaphore(int initialValue, const char* name)
|
||||
} else {
|
||||
/* Anonymous semaphore shared between threads */
|
||||
int shared = 0; // 1 if sharing between processes
|
||||
fPSema = new sem_t;
|
||||
int status = sem_init(fPSema, shared, initialValue);
|
||||
hsThrowIfOSErr(status);
|
||||
}
|
||||
@ -307,6 +308,7 @@ hsSemaphore::~hsSemaphore()
|
||||
} else {
|
||||
status = sem_destroy(fPSema);
|
||||
}
|
||||
delete fPSema;
|
||||
hsThrowIfOSErr(status);
|
||||
#else
|
||||
int status = ::pthread_cond_destroy(&fPCond);
|
||||
@ -321,7 +323,10 @@ bool hsSemaphore::TryWait()
|
||||
{
|
||||
#ifdef USE_SEMA
|
||||
int status = ::sem_trywait(fPSema);
|
||||
return status != EAGAIN;
|
||||
if (status != 0) {
|
||||
return errno != EAGAIN;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
int status = ::pthread_mutex_trylock(&fPMutex);
|
||||
hsThrowIfOSErr(status);
|
||||
|
Reference in New Issue
Block a user