Module: RactorLocalSingleton::RactorLocalSingletonClassMethods
- Includes:
- Singleton::SingletonClassMethods
- Defined in:
- lib/singleton.rb
Instance Method Summary collapse
Methods included from Singleton::SingletonClassMethods
Instance Method Details
#instance ⇒ Object
204 205 206 207 208 209 210 211 212 |
# 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 |