TypedThreadLocalStorage
public struct TypedThreadLocalStorage<Underlying> where Underlying : RawThreadLocalStorage
Wrapper around an underlying thread local storage abstraction to provide a nicer, typed thread local storage interface.
-
Token used to index into the thread local storage.
See moreDeclaration
Swift
public struct Key<Value> where Value : AnyObject
-
Allocates a key for type
T
.Declaration
Swift
public static func makeKey<T>(for _: Type<T>) -> Key<T> where T : AnyObject
-
Retrieves the thread-local value for
key
, if it exists.Declaration
Swift
public static func get<T>(_ key: Key<T>) -> T? where T : AnyObject
-
Retrieves the thread-local value for
key
, creating it withdefaultValue
if it has not previously been set.Declaration
Swift
public static func get<T: AnyObject>( _ key: Key<T>, default defaultValue: @autoclosure () -> T ) -> T
-
Stores
newValue
in thread-local storage usingkey
.Declaration
Swift
public static func set<T>(_ newValue: T?, for key: Key<T>) where T : AnyObject