diff --git a/source/vibe/core/sync.d b/source/vibe/core/sync.d index 7ae378d..f2fdef5 100644 --- a/source/vibe/core/sync.d +++ b/source/vibe/core/sync.d @@ -33,11 +33,18 @@ shared(ManualEvent) createSharedManualEvent() return shared(ManualEvent).init; } -ScopedMutexLock!M scopedMutexLock(M : Mutex)(M mutex, LockMode mode = LockMode.lock) +ScopedMutexLock!M scopedMutexLock(M)(M mutex, LockMode mode = LockMode.lock) + if (is(M : Mutex) || is(M : Lockable)) { return ScopedMutexLock!M(mutex, mode); } +unittest { + scopedMutexLock(new Mutex); + scopedMutexLock(new TaskMutex); + scopedMutexLock(new InterruptibleTaskMutex); +} + enum LockMode { lock, tryLock, @@ -53,7 +60,8 @@ interface Lockable { /** RAII lock for the Mutex class. */ -struct ScopedMutexLock(M : Mutex = core.sync.mutex.Mutex) +struct ScopedMutexLock(M) + if (is(M : Mutex) || is(M : Lockable)) { @disable this(this); private {