ConditionMutexProtocol
public protocol ConditionMutexProtocol : MutexProtocol
Allows for waiting until a given condition is satisifed.
-
lockWhen(_:
Default implementation) Locks
self
whenpredicate
returns true.Must be called when
self
is not locked by the current thread of execution.Default Implementation
Declaration
Swift
func lockWhen(_ predicate: () -> Bool)
Parameters
predicate
A function that returns
true
when the lock should be locked by the current thread of execution.predicate
is only executed while holding the lock. -
lockWhen(_:
Default implementation_: ) Undocumented
Default Implementation
Undocumented
Declaration
Swift
func lockWhen<T>(_ predicate: () -> Bool, _ body: () throws -> T) rethrows -> T
-
Unlocks
self
untilpredicate
returnstrue
.Must be called when
self
is locked by the current thread of execution.Declaration
Swift
func await(_ predicate: () -> Bool)
Parameters
predicate
A function that returns
true
whenself
should be locked by the current thread of execution.predicate
is only executed while holding the lock.