Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
fixed testWaitTimeout on OSX. For some reason, the timeout passed to …
Browse files Browse the repository at this point in the history
…the wait routine wasn't being honored.
  • Loading branch information
complexmath committed Aug 29, 2011
1 parent 045482b commit b4a3ec7
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/core/sync/semaphore.d
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,15 @@ class Semaphore
mach_timespec_t t = void;
(cast(byte*) &t)[0 .. t.sizeof] = 0;

if( dur!("nsecs")( 0 ) == val )
if( val.total!("seconds")() > t.tv_sec.max )
{
if( val.total!("seconds")() > t.tv_sec.max )
{
t.tv_sec = t.tv_sec.max;
t.tv_nsec = cast(typeof(t.tv_nsec)) val.fracSec.nsecs;
}
else
{
t.tv_sec = cast(typeof(t.tv_sec)) val.total!("seconds")();
t.tv_nsec = cast(typeof(t.tv_nsec)) val.fracSec.nsecs;
}
t.tv_sec = t.tv_sec.max;
t.tv_nsec = cast(typeof(t.tv_nsec)) val.fracSec.nsecs;
}
else
{
t.tv_sec = cast(typeof(t.tv_sec)) val.total!("seconds")();
t.tv_nsec = cast(typeof(t.tv_nsec)) val.fracSec.nsecs;
}
while( true )
{
Expand Down Expand Up @@ -505,8 +502,8 @@ version( unittest )
}
Thread.yield();
}
alertedOne = semReady.wait( dur!"msecs"(200) );
alertedTwo = semReady.wait( dur!"msecs"(200) );
alertedOne = semReady.wait( dur!"msecs"(100) );
alertedTwo = semReady.wait( dur!"msecs"(100) );
}

auto thread = new Thread( &waiter );
Expand Down

0 comments on commit b4a3ec7

Please sign in to comment.