Skip to content
The atomic qualifier Swift was missing
Swift Ruby
Branch: master
Clone or download
Latest commit e2913c6 Oct 9, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.swiftpm/xcode Initial Commit Jun 28, 2019
Demo Update demo project Oct 2, 2019
Sources/AtomicSwift Update propertyWrapper (ex propertyDelegate) syntax Oct 2, 2019
Tests Initial Commit Jun 28, 2019
.gitignore Initial Commit Jun 28, 2019
AtomicSwift.png Add logo Oct 2, 2019
AtomicSwift.podspec Add license Oct 9, 2019
LICENSE Add license Oct 9, 2019
Package.swift Exclude demo and tests from package Oct 2, 2019
README.md Update README.md Oct 3, 2019

README.md

AtomicSwift

A property wrapper to declare atomic properties in swift

AtomicSwift: The atomic qualifier Swift was missing
Version License Platform

Installation

Pods

pod 'AtomicSwift'

Swift package manager

From Xcode, select File → Swift Packages → Add Package Dependency → Select your project → Search AtomicSwift

Usage

Just add the @Atomic qualifier before your variable declaration.

Example:


// the following example will crash

var aDictionary = [Int: Int]()

DispatchQueue.concurrentPerform(iterations: 1000) { _ in
    self.aDictionary[.random(in: 0...10000)] = "test"
}

// the following example won't crash

@Atomic
var anAtomicDictionary = [Int: Int]()

DispatchQueue.concurrentPerform(iterations: 1000) { _ in
    self.anAtomicDictionary[.random(in: 0...10000)] = "test"
}

You can’t perform that action at this time.