WaitGroup
A WaitGroup waits for a collection of operations to finish. The main operation calls ‘add’ to set the number of operation to wait for. Then each of the operations runs and calls ‘done’ when finished. At the same time, 'wait’ can be used to block until all operations have finished.
-
Returns a new WaitGroup.
Declaration
Swift
public init() {}
-
Adds delta, which may be negative, to the WaitGroup counter. If the counter becomes Zero, all operations blocked on ‘wait’ are released. If the counter goes negative, ‘add’ fires a system exception.
Note that calls with a positive delta that occur when the counter is Zero must happen before a 'wait’. Calls with a negative delta, or calls with a positive delta that start when the counter is greater than zero, may happen at any time. Typically this means the calls to 'add’ should execute before the statement creating the operation or other event to be waited for.
Declaration
Swift
public func add(delta: Int)
-
Decrements the WaitGroup counter.
Declaration
Swift
public func done()
-
Blocks until the WaitGroup counter is Zero.
Declaration
Swift
public func wait()