Make scopedMutexLock work with InterruptibleTaskMutex.

This commit is contained in:
Sönke Ludwig 2019-01-14 00:07:38 +01:00
parent 452fa411c2
commit fb64c07d3c

View file

@ -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 {