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)
83
83
#
84
84
# @return [Object] the current value
85
85
def value
86
- if array = Thread . current [ :__threadlocal_array__ ]
86
+ if array = Thread . current . thread_variable_get ( :__threadlocal_array__ )
87
87
value = array [ @index ]
88
88
if value . nil?
89
89
@default
@@ -106,8 +106,8 @@ def value=(value)
106
106
# We could keep the thread-local arrays in a hash, keyed by Thread
107
107
# But why? That would require locking
108
108
# 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__ , [ ] )
111
111
LOCK . synchronize { ARRAYS [ array . object_id ] = array }
112
112
ObjectSpace . define_finalizer ( me , self . class . thread_finalizer ( array ) )
113
113
end
You can’t perform that action at this time.
0 commit comments