How do I atomically increment a variable in Swift?
import Foundation struct AtomicInteger : BinaryInteger where Type: BinaryInteger { typealias Magnitude = Type.Magnitude typealias IntegerLiteralType = Type.IntegerLiteralType typealias Words = Type.Words fileprivate var value: Type private var semaphore = DispatchSemaphore(value: 1) fileprivate func _wait() { semaphore.wait() } fileprivate func _signal() { semaphore.signal() } init() { value = Type() } init(integerLiteral value: AtomicInteger.IntegerLiteralType) { self.value = Type(integerLiteral: value) } init (_ source: T) where T : BinaryInteger { value = Type(source) } init(_ source: Int) { value = Type(source) } init (clamping source: T) where T : BinaryInteger { value = Type(clamping: source) } init?