Showing with 55 additions and 38 deletions.
  1. +0 −1 src/core/sync/barrier.d
  2. +7 −2 src/core/sync/condition.d
  3. +14 −11 src/core/sync/mutex.d
  4. +0 −3 src/core/sync/rwmutex.d
  5. +0 −1 src/core/sync/semaphore.d
  6. +19 −14 src/core/thread.d
  7. +9 −0 src/gc/gc.d
  8. +2 −2 src/object.di
  9. +4 −4 src/object_.d
1 change: 0 additions & 1 deletion src/core/sync/barrier.d
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ else version( Posix )
*/
class Barrier
{
nothrow:
////////////////////////////////////////////////////////////////////////////
// Initialization
////////////////////////////////////////////////////////////////////////////
Expand Down
9 changes: 7 additions & 2 deletions src/core/sync/condition.d
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ else
*/
class Condition
{
nothrow:
////////////////////////////////////////////////////////////////////////////
// Initialization
////////////////////////////////////////////////////////////////////////////
Expand All @@ -70,7 +69,7 @@ nothrow:
* Throws:
* SyncError on error.
*/
this( Mutex m ) @safe
this( Mutex m ) nothrow @safe
{
version( Windows )
{
Expand Down Expand Up @@ -131,6 +130,12 @@ nothrow:
return m_assocMutex;
}

// undocumented function for internal use
final @property Mutex mutex_nothrow() pure nothrow @safe @nogc
{
return m_assocMutex;
}


////////////////////////////////////////////////////////////////////////////
// General Actions
Expand Down
25 changes: 14 additions & 11 deletions src/core/sync/mutex.d
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ else
class Mutex :
Object.Monitor
{
nothrow:
////////////////////////////////////////////////////////////////////////////
// Initialization
////////////////////////////////////////////////////////////////////////////
Expand All @@ -59,7 +58,7 @@ nothrow:
* Throws:
* SyncError on error.
*/
this() @trusted
this() nothrow @trusted
{
version( Windows )
{
Expand Down Expand Up @@ -90,7 +89,7 @@ nothrow:
* In:
* o must not already have a monitor.
*/
this( Object o )
this( Object o ) nothrow @trusted
in
{
assert( o.__monitor is null );
Expand Down Expand Up @@ -130,6 +129,12 @@ nothrow:
* SyncError on error.
*/
@trusted void lock()
{
lock_nothrow();
}

// undocumented function for internal use
final void lock_nothrow() nothrow @trusted
{
version( Windows )
{
Expand All @@ -143,10 +148,6 @@ nothrow:
}
}

// TBD in 2.067
// deprecated("Please use lock instead")
alias lock_nothrow = lock;

/**
* Decrements the internal lock count by one. If this brings the count to
* zero, the lock is released.
Expand All @@ -155,6 +156,12 @@ nothrow:
* SyncError on error.
*/
@trusted void unlock()
{
unlock_nothrow();
}

// undocumented function for internal use
final void unlock_nothrow() nothrow @trusted
{
version( Windows )
{
Expand All @@ -168,10 +175,6 @@ nothrow:
}
}

// TBD in 2.067
// deprecated("Please use unlock instead")
alias unlock_nothrow = unlock;

/**
* If the lock is held by another caller, the method returns. Otherwise,
* the lock is acquired if it is not already held, and then the internal
Expand Down
3 changes: 0 additions & 3 deletions src/core/sync/rwmutex.d
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ else version( Posix )
*/
class ReadWriteMutex
{
nothrow:
/**
* Defines the policy used by this mutex. Currently, two policies are
* defined.
Expand Down Expand Up @@ -168,7 +167,6 @@ nothrow:
class Reader :
Object.Monitor
{
nothrow:
/**
* Initializes a read/write mutex reader proxy object.
*/
Expand Down Expand Up @@ -272,7 +270,6 @@ nothrow:
class Writer :
Object.Monitor
{
nothrow:
/**
* Initializes a read/write mutex writer proxy object.
*/
Expand Down
1 change: 0 additions & 1 deletion src/core/sync/semaphore.d
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ else
*/
class Semaphore
{
nothrow:
////////////////////////////////////////////////////////////////////////////
// Initialization
////////////////////////////////////////////////////////////////////////////
Expand Down
33 changes: 19 additions & 14 deletions src/core/thread.d
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,8 @@ class Thread
// app without ever knowing that it should have waited for this
// starting thread. In effect, not doing the add here risks
// having thread being treated like a daemon thread.
synchronized( slock )
slock.lock_nothrow();
scope(exit) slock.unlock_nothrow();
{
version( Windows )
{
Expand Down Expand Up @@ -1638,7 +1639,8 @@ private:

while( true )
{
synchronized( slock )
slock.lock_nothrow();
scope(exit) slock.unlock_nothrow();
{
if( !suspendDepth )
{
Expand Down Expand Up @@ -1728,7 +1730,8 @@ private:

while( true )
{
synchronized( slock )
slock.lock_nothrow();
scope(exit) slock.unlock_nothrow();
{
if( !suspendDepth )
{
Expand Down Expand Up @@ -1758,7 +1761,7 @@ private:
}
body
{
slock.lock();
slock.lock_nothrow();
{
// NOTE: When a thread is removed from the global thread list its
// main context is invalid and should be removed as well.
Expand All @@ -1785,7 +1788,7 @@ private:
// function, however, a thread should never be re-added to the
// list anyway and having next and prev be non-null is a good way
// to ensure that.
slock.unlock();
slock.unlock_nothrow();
}
}

Expand Down Expand Up @@ -2185,7 +2188,8 @@ unittest
*/
static Thread thread_findByAddr( Thread.ThreadAddr addr )
{
synchronized( Thread.slock )
Thread.slock.lock_nothrow();
scope(exit) Thread.slock.unlock_nothrow();
{
foreach( t; Thread )
{
Expand Down Expand Up @@ -2561,7 +2565,7 @@ extern (C) void thread_suspendAll() nothrow
return;
}

Thread.slock.lock();
Thread.slock.lock_nothrow();
{
if( ++suspendDepth > 1 )
return;
Expand All @@ -2574,7 +2578,7 @@ extern (C) void thread_suspendAll() nothrow
// cause the second suspend to fail, the garbage collection to
// abort, and Bad Things to occur.

Thread.criticalRegionLock.lock();
Thread.criticalRegionLock.lock_nothrow();
for (Thread t = Thread.sm_tbeg; t !is null; t = t.next)
{
Duration waittime = dur!"usecs"(10);
Expand All @@ -2585,18 +2589,18 @@ extern (C) void thread_suspendAll() nothrow
}
else if (t.m_isInCriticalRegion)
{
Thread.criticalRegionLock.unlock();
Thread.criticalRegionLock.unlock_nothrow();
Thread.sleep(waittime);
if (waittime < dur!"msecs"(10)) waittime *= 2;
Thread.criticalRegionLock.lock();
Thread.criticalRegionLock.lock_nothrow();
goto Lagain;
}
else
{
suspend(t);
}
}
Thread.criticalRegionLock.unlock();
Thread.criticalRegionLock.unlock_nothrow();
}
}

Expand Down Expand Up @@ -2695,7 +2699,7 @@ body
return;
}

scope(exit) Thread.slock.unlock();
scope(exit) Thread.slock.unlock_nothrow();
{
if( --suspendDepth > 0 )
return;
Expand Down Expand Up @@ -4361,8 +4365,9 @@ private:
{
// NOTE: m_ctxt is guaranteed to be alive because it is held in the
// global context list.
synchronized( Thread.slock )
Thread.remove( m_ctxt );
Thread.slock.lock_nothrow();
scope(exit) Thread.slock.unlock_nothrow();
Thread.remove( m_ctxt );

static if( __traits( compiles, VirtualAlloc ) )
{
Expand Down
9 changes: 9 additions & 0 deletions src/gc/gc.d
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ const uint GCVERSION = 1; // increment every time we change interface
// This just makes Mutex final to de-virtualize member function calls.
final class GCMutex : Mutex
{
final override void lock() nothrow @trusted
{
super.lock_nothrow();
}

final override void unlock() nothrow @trusted
{
super.unlock_nothrow();
}
}

struct GC
Expand Down
4 changes: 2 additions & 2 deletions src/object.di
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class Object

interface Monitor
{
void lock() nothrow;
void unlock() nothrow;
void lock();
void unlock();
}

static Object factory(string classname);
Expand Down
8 changes: 4 additions & 4 deletions src/object_.d
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ class Object

interface Monitor
{
void lock() nothrow;
void unlock() nothrow;
void lock();
void unlock();
}

/**
Expand Down Expand Up @@ -1860,7 +1860,7 @@ extern (C) void _d_monitordelete(Object h, bool det)
}
}

extern (C) void _d_monitorenter(Object h) nothrow
extern (C) void _d_monitorenter(Object h)
{
Monitor* m = getMonitor(h);

Expand All @@ -1880,7 +1880,7 @@ extern (C) void _d_monitorenter(Object h) nothrow
i.lock();
}

extern (C) void _d_monitorexit(Object h) nothrow
extern (C) void _d_monitorexit(Object h)
{
Monitor* m = getMonitor(h);
IMonitor i = m.impl;
Expand Down