Skip to content

A Custom library which helps to make class properties have Objective-C's Atomic like attribute for multi-threading

Notifications You must be signed in to change notification settings

IMSEONGJUN/AtomicMaker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

AtomicMaker

  • A Custom library which helps to make class properties have Objective-C's Atomic like attribute for multi-threading
final class Atomic<T> {
    private let queue = DispatchQueue(label: "Atomic serial queue")
    
    private var _value: T
    
    init(_ value: T) {
        self._value = value
    }

    var value: T {
        get {
            return queue.sync { self._value }
        }
    }

    func mutate(_ transform: (inout T) -> ()) {
        queue.sync {
            transform(&self._value)
        }
    }
}

About

A Custom library which helps to make class properties have Objective-C's Atomic like attribute for multi-threading

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published