Cond
Cond implements a condition variable, a rendezvous point for an operation waiting for or announcing the occurrence of an event.
Each Cond has an associated Mutex, which must be held when changing the condition and when calling the wait method.
-
Returns a new Cond. - Parameter mutex: A Mutex object.
Declaration
Swift
public init(_ mutex : Mutex) -
Wakes all operations waiting on
Cond.Declaration
Swift
public func broadcast() -
Wakes one operations waiting on
Cond.Declaration
Swift
public func signal() -
Atomically unlocks
.mutexand suspends execution of the calling operation. After later resuming execution,waita locks.mutex’ before returning. Unlike in other systems,waitcannot return unless awoken bybroadcastorsignal', or thetimeout` param has been reached.Because
.mutexis not locked when ‘wait first resumes, the caller typically cannot assume that the condition is true whenwaitreturns. Instead, the caller shouldwaitin a loop:cond.mutex.lock() while !condition() { cond.mutex.wait() } ... make use of condition ... cond.mutex.unlock()Declaration
Swift
public func wait(timeout : NSTimeInterval = -1) -> WaitResult
View on GitHub
Cond Class Reference