class Concurrent::FiberLocals

An array-backed storage of indexed variables per fiber.
@!macro internal_implementation_note
@!visibility private

def locals

def locals
  Thread.current[:concurrent_fiber_locals]
end

def locals!

def locals!
  thread = Thread.current
  locals = thread[:concurrent_fiber_locals]
  unless locals
    locals = thread[:concurrent_fiber_locals] = []
    weak_synchronize do
      @all_arrays[locals.object_id] = locals
    end
    # When the fiber goes out of scope, we should delete the associated locals:
    ObjectSpace.define_finalizer(Fiber.current, thread_fiber_finalizer(locals.object_id))
  end
  locals
end