diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-14 16:50:16 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-14 16:50:16 +0000 |
commit | 970df0d1385ea23c453f4779050a31c4379d6d11 (patch) | |
tree | b1bb745b00858777df90634aa4fc961099ba8045 /lib | |
parent | fdf4aa982f8265402ec6ecfa137bf2bc4052560d (diff) | |
download | ruby-970df0d1385ea23c453f4779050a31c4379d6d11.tar.gz |
* 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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/delegate.rb | 16 | ||||
-rw-r--r-- | lib/singleton.rb | 24 |
2 files changed, 20 insertions, 20 deletions
diff --git a/lib/delegate.rb b/lib/delegate.rb index 8574bc39ec..b5ebaa15da 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -95,15 +95,15 @@ # class SimpleDelegator < Delegator # def initialize(obj) # super # pass obj to Delegator constructor, required -# @_sd_obj = obj # store obj for future use +# @delegate_sd_obj = obj # store obj for future use # end # # def __getobj__ -# @_sd_obj # return object we are delegating to, required +# @delegate_sd_obj # return object we are delegating to, required # end # # def __setobj__(obj) -# @_sd_obj = obj # change delegation object, a feature we're providing +# @delegate_sd_obj = obj # change delegation object, a feature we're providing # end # # # ... @@ -219,7 +219,7 @@ end class SimpleDelegator<Delegator # Returns the current object method calls are being delegated to. def __getobj__ - @_sd_obj + @delegate_sd_obj end # @@ -238,7 +238,7 @@ class SimpleDelegator<Delegator # def __setobj__(obj) raise ArgumentError, "cannot delegate to self" if self.equal?(obj) - @_sd_obj = obj + @delegate_sd_obj = obj end end @@ -269,11 +269,11 @@ def DelegateClass(superclass) klass.module_eval { include Delegator::MethodDelegation def __getobj__ # :nodoc: - @_dc_obj + @delegate_dc_obj end def __setobj__(obj) # :nodoc: raise ArgumentError, "cannot delegate to self" if self.equal?(obj) - @_dc_obj = obj + @delegate_dc_obj = obj end } for method in methods @@ -281,7 +281,7 @@ def DelegateClass(superclass) klass.module_eval <<-EOS, __FILE__, __LINE__+1 def #{method}(*args, &block) begin - @_dc_obj.__send(:#{method}, *args, &block) + @delegate_dc_obj.__send(:#{method}, *args, &block) rescue $@[0,2] = nil raise 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 |