From 970df0d1385ea23c453f4779050a31c4379d6d11 Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 14 Feb 2007 16:50:16 +0000 Subject: * lib/delegate.rb: catch up with class local variable (@_v) spec. * lib/singleton.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/singleton.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lib/singleton.rb') diff --git a/lib/singleton.rb b/lib/singleton.rb index 2c08f35e37..acacfc48c7 100644 --- a/lib/singleton.rb +++ b/lib/singleton.rb @@ -39,7 +39,7 @@ # method body is a simple: # # def Klass.instance() -# return @__instance__ +# return @singleton__instance__ # end # # * Klass._load(str) - calling Klass.instance() @@ -101,16 +101,16 @@ module Singleton class << Singleton def __init__(klass) klass.instance_eval { - @__instance__ = nil - @__mutex__ = Mutex.new + @singleton__instance__ = nil + @singleton__mutex__ = Mutex.new } def klass.instance - return @__instance__ if @__instance__ - @__mutex__.synchronize { - return @__instance__ if @__instance__ - @__instance__ = new() + return @singleton__instance__ if @singleton__instance__ + @singleton__mutex__.synchronize { + return @singleton__instance__ if @singleton__instance__ + @singleton__instance__ = new() } - @__instance__ + @singleton__instance__ end klass end @@ -177,13 +177,13 @@ end class << Ups def _instantiate? @enter.push Thread.current[:i] - while false.equal?(@__instance__) - @__mutex__.unlock + while false.equal?(@singleton__instance__) + @singleton__mutex__.unlock sleep 0.08 - @__mutex__.lock + @singleton__mutex__.lock end @leave.push Thread.current[:i] - @__instance__ + @singleton__instance__ end def __sleep -- cgit v1.2.3