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