Module: Puppet::Concurrent::ThreadLocalSingleton

Instance Method Summary collapse

Instance Method Details

#singletonObject



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

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