mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
28 lines
487 B
Swift
28 lines
487 B
Swift
//
|
|
// Atomic.swift
|
|
//
|
|
//
|
|
// Created by Vladislav Lisianskii on 23.02.2022.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
@propertyWrapper
|
|
struct Atomic<Value> {
|
|
private let queue = DispatchQueue(label: "com.xcodegencore.atomic")
|
|
private var value: Value
|
|
|
|
init(wrappedValue: Value) {
|
|
self.value = wrappedValue
|
|
}
|
|
|
|
var wrappedValue: Value {
|
|
get {
|
|
return queue.sync { value }
|
|
}
|
|
set {
|
|
queue.sync { value = newValue }
|
|
}
|
|
}
|
|
}
|