module RactorLocalSingleton::RactorLocalSingletonClassMethods

Public Instance Methods

instance ()
# File lib/singleton.rb, line 204
def instance
  set_mutex(Thread::Mutex.new) if Ractor.current[mutex_key].nil?
  return Ractor.current[instance_key] if Ractor.current[instance_key]
  Ractor.current[mutex_key].synchronize {
    return Ractor.current[instance_key] if Ractor.current[instance_key]
    set_instance(new())
  }
  Ractor.current[instance_key]
end