Skip to content

Commit ad0347f

Browse files
committed
Returned erroneously removed ThreadLocalvar#value_for method.
1 parent 0bd6a48 commit ad0347f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lib/concurrent/atomic/thread_local_var.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,25 @@ def bind(value, &block)
8787
def allocate_storage
8888
raise NotImplementedError
8989
end
90+
91+
private
92+
93+
# This exists only for use in testing
94+
# @!visibility private
95+
def value_for(thread)
96+
if array = thread.thread_variable_get(:__threadlocal_array__)
97+
value = array[@index]
98+
if value.nil?
99+
@default
100+
elsif value.equal?(NIL_SENTINEL)
101+
nil
102+
else
103+
value
104+
end
105+
else
106+
@default
107+
end
108+
end
90109
end
91110

92111
# @!visibility private

0 commit comments

Comments
 (0)