The following structures are available globally.
OSUnfairLockis a wrapper around an unfair lock that locks around accesses to a stored object. It has the same API as
Despite being a
struct, it isn’t a value type, as copied instances control the same underlying lock allocation.
Prefer storing state protected by the lock in
State. Containing locked state inside the lock helps track what is protected state and provides a scope where it is safe to access that state.
OSUnfairLockwith external state, nonscoped locking allows more flexible locking patterns by using
unlock(), but offers no assistance in tracking what state is protected by the lock.
This lock must be unlocked from the same thread that locked it. As such, it is unsafe to use
awaitsuspension point. Instead, use
withLockto enforce that the lock is only held within a synchronous scope.
If you are using a lock from asynchronous contexts only, prefer using an actor instead.
This lock is not a recursive lock. Attempting to lock it again from the same thread while the lock is already locked will crash.See more
public struct OSUnfairLock<State> : @unchecked Sendable
A type that conforms toSee more
DynamicPropertyto facilitate automatically updating SwiftUI
@available(iOS 13, tvOS 13, watchOS 6, macOS 10.15, *) @propertyWrapper public struct PersistStorage<Value> : DynamicProperty