[ruby/singleton] Change PerRactorSingleton to RactorLocalSingleton

https://github.com/ruby/singleton/commit/1216a86303
This commit is contained in:
rm155 2021-07-31 16:17:55 -04:00 committed by Hiroshi SHIBATA
parent 136b30b414
commit a6e96df573
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2

View File

@ -196,10 +196,10 @@ module Singleton
# Returns the singleton instance. # Returns the singleton instance.
end end
module PerRactorSingleton module RactorLocalSingleton
include Singleton::SingletonInstanceMethods include Singleton::SingletonInstanceMethods
module PerRactorSingletonClassMethods module RactorLocalSingletonClassMethods
include Singleton::SingletonClassMethods include Singleton::SingletonClassMethods
def instance def instance
set_mutex(Thread::Mutex.new) if Ractor.current[mutex_key].nil? set_mutex(Thread::Mutex.new) if Ractor.current[mutex_key].nil?
@ -214,11 +214,11 @@ module PerRactorSingleton
private private
def instance_key def instance_key
:"__PerRactorSingleton_instance_with_class_id_#{object_id}__" :"__RactorLocalSingleton_instance_with_class_id_#{object_id}__"
end end
def mutex_key def mutex_key
:"__PerRactorSingleton_mutex_with_class_id_#{object_id}__" :"__RactorLocalSingleton_mutex_with_class_id_#{object_id}__"
end end
def set_instance(val) def set_instance(val)
@ -231,7 +231,7 @@ module PerRactorSingleton
end end
def self.module_with_class_methods def self.module_with_class_methods
PerRactorSingletonClassMethods RactorLocalSingletonClassMethods
end end
extend Singleton::SingletonClassProperties extend Singleton::SingletonClassProperties