From fb64c07d3cfe9690253b1b36ab7521beb059eac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Mon, 14 Jan 2019 00:07:38 +0100 Subject: [PATCH] Make scopedMutexLock work with InterruptibleTaskMutex. --- source/vibe/core/sync.d | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 {