Classes
The following classes are available globally.
-
Atomic is a class that allows for atomic loading and storing of objects.atomic
var ai = Atomic<Int>(15) ai += 10 print(ai) // prints 25
There are a number of helper aliases for common types such as IntA, StringA, BoolA
See morevar ai = IntA(15) ai += 10 print(ai) // prints 25
Declaration
Swift
public class Atomic<T> : CustomStringConvertible
-
A Mutex is a mutual exclusion lock.
See moreDeclaration
Swift
public class Mutex
-
Cond
implements a condition variable, a rendezvous point for an operation waiting for or announcing the occurrence of an event.Each
See moreCond
has an associatedMutex
, which must be held when changing the condition and when calling thewait
method.Declaration
Swift
public class Cond
-
Once is an object that will perform exactly one action.
See moreDeclaration
Swift
public class Once
-
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.
See moreDeclaration
Swift
public class WaitGroup
-
Channels are the pipes that connect concurrent operations. You can send values into channels from one operation and receive those values into another operation.
See morevar messages = Chan<String>() dispatch { messages <- "ping" } if let msg := <-messages { println(msg) }
Declaration
Swift
public class Chan<T> : SequenceType