class ThreadAttrAccessor::FiberStorage

Attributes

fiber[R]
thread[R]

Public Class Methods

new(fiber = Fiber.current, thread = Thread.current) click to toggle source
# File lib/thread_attr_accessor.rb, line 33
def initialize(fiber = Fiber.current, thread = Thread.current)
  @fiber  = fiber
  @thread = thread
end

Public Instance Methods

[](key) click to toggle source
# File lib/thread_attr_accessor.rb, line 38
def [](key)
  fiber.fiber_variable_get(key)
end
[]=(key, value) click to toggle source
# File lib/thread_attr_accessor.rb, line 42
def []=(key, value)
  fiber.fiber_variable_set(key, value)
  if fiber.parent_fiber.nil?
    thread.thread_variable_set(key, value)
  end

  value
end
has_key?(key) click to toggle source
# File lib/thread_attr_accessor.rb, line 51
def has_key?(key)
  fiber.fiber_variable?(key)
end