Spec-Zone.ru › Ruby 3.4

модуль RactorLocalSingleton::RactorLocalSingletonClassMethods

Публичные методы экземпляра

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

Приватные методы экземпляра

instance_key ()
Исходный код
# File lib/singleton.rb, line 216
def instance_key
  :"__RactorLocalSingleton_instance_with_class_id_#{object_id}__"
end
mutex_key ()
Исходный код
# File lib/singleton.rb, line 220
def mutex_key
  :"__RactorLocalSingleton_mutex_with_class_id_#{object_id}__"
end
set_instance (val)
Исходный код
# File lib/singleton.rb, line 224
def set_instance(val)
  Ractor.current[instance_key] = val
end
set_mutex (val)
Исходный код
# File lib/singleton.rb, line 228
def set_mutex(val)
  Ractor.current[mutex_key] = val
end

Ruby Core © 1993–2024 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API