Module: Puppet::Concurrent::ThreadLocalSingleton

Instance Method Summary collapse

Instance Method Details

#singletonObject


5
6
7
8
9
10
11
12
13
14
# File 'lib/puppet/concurrent/thread_local_singleton.rb', line 5

def singleton
  key = (name + ".singleton").intern
  thread = Thread.current
  value = thread.thread_variable_get(key)
  if value.nil?
    value = new
    thread.thread_variable_set(key, value)
  end
  value
end