File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ def initialize(default = nil)
8383 #
8484 # @return [Object] the current value
8585 def value
86- if array = Thread . current [ :__threadlocal_array__ ]
86+ if array = Thread . current . thread_variable_get ( :__threadlocal_array__ )
8787 value = array [ @index ]
8888 if value . nil?
8989 @default
@@ -106,8 +106,8 @@ def value=(value)
106106 # We could keep the thread-local arrays in a hash, keyed by Thread
107107 # But why? That would require locking
108108 # Using Ruby's built-in thread-local storage is faster
109- unless array = me [ :__threadlocal_array__ ]
110- array = me [ :__threadlocal_array__ ] = [ ]
109+ unless array = me . thread_variable_get ( :__threadlocal_array__ )
110+ array = me . thread_variable_set ( :__threadlocal_array__ , [ ] )
111111 LOCK . synchronize { ARRAYS [ array . object_id ] = array }
112112 ObjectSpace . define_finalizer ( me , self . class . thread_finalizer ( array ) )
113113 end
You can’t perform that action at this time.
0 commit comments