ruby-changes:56250
From: Nobuyoshi <ko1@a...>
Date: Fri, 28 Jun 2019 14:36:55 +0900 (JST)
Subject: [ruby-changes:56250] Nobuyoshi Nakada: 2d1728b9ce (trunk): Moved Singleton.instance to get rid of redefinition
https://git.ruby-lang.org/ruby.git/commit/?id=2d1728b9ce From 2d1728b9cede877ac45f5760ebf214d25685b285 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 28 Jun 2019 14:23:22 +0900 Subject: Moved Singleton.instance to get rid of redefinition diff --git a/lib/singleton.rb b/lib/singleton.rb index 368febc..b433208 100644 --- a/lib/singleton.rb +++ b/lib/singleton.rb @@ -120,6 +120,15 @@ module Singleton https://github.com/ruby/ruby/blob/trunk/lib/singleton.rb#L120 instance end + def instance # :nodoc: + return @singleton__instance__ if @singleton__instance__ + @singleton__mutex__.synchronize { + return @singleton__instance__ if @singleton__instance__ + @singleton__instance__ = new() + } + @singleton__instance__ + end + private def inherited(sub_klass) @@ -134,14 +143,6 @@ module Singleton https://github.com/ruby/ruby/blob/trunk/lib/singleton.rb#L143 @singleton__instance__ = nil @singleton__mutex__ = Thread::Mutex.new } - def klass.instance # :nodoc: - return @singleton__instance__ if @singleton__instance__ - @singleton__mutex__.synchronize { - return @singleton__instance__ if @singleton__instance__ - @singleton__instance__ = new() - } - @singleton__instance__ - end klass end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/