class Concurrent::ThreadLocals
An array-backed storage of indexed variables per thread.
@!macro internal_implementation_note
@!visibility private
def locals
def locals Thread.current.thread_variable_get(:concurrent_thread_locals) end
def locals!
def locals! thread = Thread.current locals = thread.thread_variable_get(:concurrent_thread_locals) unless locals locals = thread.thread_variable_set(:concurrent_thread_locals, []) weak_synchronize do @all_arrays[locals.object_id] = locals end # When the thread goes out of scope, we should delete the associated locals: ObjectSpace.define_finalizer(thread, thread_fiber_finalizer(locals.object_id)) end locals end