ThreadSpecificVariable
A ThreadSpecificVariable
is a variable that can be read and set like a normal variable except that it holds different variables per thread.
final class ThreadSpecificVariable<Value> where Value : AnyObject
ThreadSpecificVariable
is thread-safe so it can be used with multiple threads at the same time but the value returned by currentValue
is defined per thread.
Citizens in NIOPosix
Type members
init(
) Initialize a new
ThreadSpecificVariable
without a current value (currentValue == nil
).init(value: Value
) Initialize a new
ThreadSpecificVariable
withvalue
for the calling thread. After calling this, the calling thread will seecurrentValue == value
but on all other threadscurrentValue
will benil
until changed.
Instance members
var currentValue: Value?
The value for the current thread.
Citizens in NIOPosix
where Value:Sendable
Conformances
protocol Sendable
A type whose values can safely be passed across concurrency domains by copying.