123456789_123456789_123456789_123456789_123456789_

Module: ActiveSupport::IsolatedExecutionState

Do not use. This module is for internal use only.
Relationships & Source Files
Defined in: activesupport/lib/active_support/isolated_execution_state.rb

Class Attribute Summary

Class Method Summary

Instance Attribute Summary

Class Attribute Details

.isolation_level (rw)

[ GitHub ]

  
# File 'activesupport/lib/active_support/isolated_execution_state.rb', line 13

attr_reader :isolation_level, :scope

.isolation_level=(level) (rw)

[ GitHub ]

  
# File 'activesupport/lib/active_support/isolated_execution_state.rb', line 15

def isolation_level=(level)
  return if level == @isolation_level

  unless %i(thread fiber).include?(level)
    raise ArgumentError, "isolation_level must be `:thread` or `:fiber`, got: `#{level.inspect}`"
  end

  clear if @isolation_level

  @scope =
    case level
    when :thread; Thread
    when :fiber; Fiber
    end

  @isolation_level = level
end

.scope (readonly)

[ GitHub ]

  
# File 'activesupport/lib/active_support/isolated_execution_state.rb', line 13

attr_reader :isolation_level, :scope

Class Method Details

.[](key)

[ GitHub ]

  
# File 'activesupport/lib/active_support/isolated_execution_state.rb', line 37

def [](key)
  state[key]
end

.[]=(key, value)

[ GitHub ]

  
# File 'activesupport/lib/active_support/isolated_execution_state.rb', line 41

def []=(key, value)
  state[key] = value
end

.clear

[ GitHub ]

  
# File 'activesupport/lib/active_support/isolated_execution_state.rb', line 53

def clear
  state.clear
end

.context

[ GitHub ]

  
# File 'activesupport/lib/active_support/isolated_execution_state.rb', line 57

def context
  scope.current
end

.delete(key)

[ GitHub ]

  
# File 'activesupport/lib/active_support/isolated_execution_state.rb', line 49

def delete(key)
  state.delete(key)
end

.key?(key) ⇒ Boolean

[ GitHub ]

  
# File 'activesupport/lib/active_support/isolated_execution_state.rb', line 45

def key?(key)
  state.key?(key)
end

.share_with(other)

[ GitHub ]

  
# File 'activesupport/lib/active_support/isolated_execution_state.rb', line 61

def share_with(other)
  # Action Controller streaming spawns a new thread and copy thread locals.
  # We do the same here for backward compatibility, but this is very much a hack
  # and streaming should be rethought.
  context.active_support_execution_state = other.active_support_execution_state.dup
end

.state (private)

[ GitHub ]

  
# File 'activesupport/lib/active_support/isolated_execution_state.rb', line 69

def state
  context.active_support_execution_state ||= {}
end

.unique_id

[ GitHub ]

  
# File 'activesupport/lib/active_support/isolated_execution_state.rb', line 33

def unique_id
  self[:__id__] ||= Object.new
end

Instance Attribute Details

#active_support_execution_state (rw)

[ GitHub ]

  
# File 'activesupport/lib/active_support/isolated_execution_state.rb', line 9

Thread.attr_accessor :active_support_execution_state