mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-28 07:45:40 +00:00
Source changes needed for Linux build.
This commit is contained in:
parent
109a766748
commit
d2700f881c
16 changed files with 73 additions and 27 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue