Skip to content

Commit 63a6907

Browse files
authored
Merge pull request #884 from ruby-concurrency/thread-local
Do not iterate over hash which might conflict with new pair addition
2 parents 31669c6 + c4cbc96 commit 63a6907

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/concurrent-ruby/concurrent/atomic/ruby_thread_local_var.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ def self.thread_local_finalizer(index)
9797
# The cost of GC'ing a TLV is linear in the number of threads using TLVs
9898
# But that is natural! More threads means more storage is used per TLV
9999
# So naturally more CPU time is required to free more storage
100-
THREAD_LOCAL_ARRAYS.each_value { |array| array[index] = nil }
100+
#
101+
# DO NOT use each_value which might conflict with new pair assignment
102+
# into the hash in #value= method
103+
THREAD_LOCAL_ARRAYS.values.each { |array| array[index] = nil }
101104
# free index has to be published after the arrays are cleared
102105
FREE.push(index)
103106
end

0 commit comments

Comments
 (0)