Skip to content

Commit

Permalink
Merge pull request #8795 from joshcooper/lexer2_not_a_singleton_11236
Browse files Browse the repository at this point in the history
(PUP-11236) Work around Thread#thread_variable? bug
  • Loading branch information
joshcooper committed Oct 15, 2021
2 parents d74d117 + 1ce7d99 commit 0853161
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/puppet/concurrent/thread_local_singleton.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ module ThreadLocalSingleton
def singleton
key = (name + ".singleton").intern
thread = Thread.current
unless thread.thread_variable?(key)
thread.thread_variable_set(key, new)
value = thread.thread_variable_get(key)
if value.nil?
value = new
thread.thread_variable_set(key, value)
end
thread.thread_variable_get(key)
value
end
end
end
Expand Down

0 comments on commit 0853161

Please sign in to comment.