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

Commit

Permalink
mark Thread.sleep as nothrow
Browse files Browse the repository at this point in the history
- nanosleep can only fail on invalid arguments
  which would be a bug in druntime itself
  • Loading branch information
MartinNowak committed Jan 20, 2015
1 parent 4bd360d commit bd31217
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/core/thread.d
Expand Up @@ -1044,7 +1044,7 @@ class Thread
*
* ------------------------------------------------------------------------
*/
static void sleep( Duration val )
static void sleep( Duration val ) nothrow
in
{
assert( !val.isNegative );
Expand Down Expand Up @@ -1087,7 +1087,7 @@ class Thread
if( !nanosleep( &tin, &tout ) )
return;
if( errno != EINTR )
throw new ThreadException( "Unable to sleep for the specified duration" );
throw new ThreadError( "Unable to sleep for the specified duration" );
tin = tout;
}
}
Expand Down Expand Up @@ -2577,16 +2577,7 @@ extern (C) void thread_suspendAll() nothrow
else if (t.m_isInCriticalRegion)
{
Thread.criticalRegionLock.unlock();
try
{
Thread.sleep(waittime);
}
catch(Exception)
{
// if sleep actually fails, it tries to allocate the new exception
// which fails the GC recursion check, so we don't expect to ever
// reach this point, but we have to convince the compiler, too
}
Thread.sleep(waittime);
if (waittime < dur!"msecs"(10)) waittime *= 2;
Thread.criticalRegionLock.lock();
goto Lagain;
Expand Down

0 comments on commit bd31217

Please sign in to comment.