Source changes needed for Linux build.

This commit is contained in:
bank 2012-09-23 14:18:12 +04:00 committed by bank
parent 109a766748
commit d2700f881c
16 changed files with 73 additions and 27 deletions

View file

@ -55,13 +55,25 @@ Semaphore::~Semaphore()
delete mData;
}
bool Semaphore::acquire(bool block)
bool Semaphore::acquire(bool block, S32 timeoutMS)
{
AssertFatal(mData, "Semaphore::acquire - Invalid semaphore.");
AssertFatal(mData && mData->semaphore, "Semaphore::acquire - Invalid semaphore.");
if (block)
{
if (SDL_SemWait(mData->semaphore) < 0)
AssertFatal(false, "Semaphore::acquie - Wait failed.");
// Semaphore acquiring is different from the MacOS/Win realization because SDL_SemWaitTimeout() with "infinite" timeout can be too heavy on some platforms.
// (see "man SDL_SemWaitTimeout(3)" for more info)
// "man" states to avoid the use of SDL_SemWaitTimeout at all, but at current stage this looks like a valid and working solution, so keeping it this way.
// [bank / Feb-2010]
if (timeoutMS == -1)
{
if (SDL_SemWait(mData->semaphore) < 0)
AssertFatal(false, "Semaphore::acquie - Wait failed.");
}
else
{
if (SDL_SemWaitTimeout(mData->semaphore, timeoutMS) < 0)
AssertFatal(false, "Semaphore::acquie - Wait with timeout failed.");
}
return (true);
}
else