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

    var ai = IntA(15)
    ai += 10
    print(ai) // prints 25
    
    See more

    Declaration

    Swift

    public class Atomic<T> : CustomStringConvertible
  • A Mutex is a mutual exclusion lock.

    See more

    Declaration

    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 Cond has an associated Mutex, which must be held when changing the condition and when calling the wait method.

    See more

    Declaration

    Swift

    public class Cond
  • Once is an object that will perform exactly one action.

    See more

    Declaration

    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 more

    Declaration

    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.

    var messages = Chan<String>()
    dispatch {
        messages <- "ping"
    }
    if let msg := <-messages {
        println(msg)
    }
    
    See more

    Declaration

    Swift

    public class Chan<T> : SequenceType