diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-12 07:17:36 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-12 07:17:36 +0000 |
| commit | c83746c9101b1e3319af8764439c19a0b140e43f (patch) | |
| tree | 1c18cec4b2c748514ac3b705b2e68feeb122337e /lib/weakref.rb | |
| parent | c2187948f778c067415db66134114978b09c581e (diff) | |
| download | ruby-c83746c9101b1e3319af8764439c19a0b140e43f.tar.gz ruby-c83746c9101b1e3319af8764439c19a0b140e43f.tar.xz ruby-c83746c9101b1e3319af8764439c19a0b140e43f.zip | |
* numeric.c (fix_equal, fix_cmp, fix_gt, fix_ge, fix_lt, fix_le):
reduce coercing when a method knows about a operand type.
[ruby-dev:26789]
* lib/delegate.rb: simplifies Delegator classes; SimpleDelegator
now uses method_missing for all methods.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@8970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/weakref.rb')
| -rw-r--r-- | lib/weakref.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/weakref.rb b/lib/weakref.rb index c790055d0..a398ebf1f 100644 --- a/lib/weakref.rb +++ b/lib/weakref.rb @@ -18,7 +18,8 @@ class WeakRef<Delegator @@id_map = {} # obj -> [ref,...] @@id_rev_map = {} # ref -> obj - @@final = lambda{|id| + @@final = lambda {|id| + printf "final: %p\n", id __old_status = Thread.critical Thread.critical = true begin @@ -42,6 +43,7 @@ class WeakRef<Delegator def initialize(orig) @__id = orig.object_id + printf "orig: %p\n", @__id ObjectSpace.define_finalizer orig, @@final ObjectSpace.define_finalizer self, @@final __old_status = Thread.critical @@ -53,7 +55,7 @@ class WeakRef<Delegator end @@id_map[@__id].push self.object_id @@id_rev_map[self.object_id] = @__id - super + super end def __getobj__ @@ -66,6 +68,8 @@ class WeakRef<Delegator Kernel::raise RefError, "Illegal Reference - probably recycled", Kernel::caller(2) end end + def __setobj__(obj) + end def weakref_alive? @@id_rev_map[self.object_id] == @__id @@ -73,11 +77,12 @@ class WeakRef<Delegator end if __FILE__ == $0 - require 'thread' +# require 'thread' foo = Object.new p foo.to_s # original's class foo = WeakRef.new(foo) p foo.to_s # should be same class ObjectSpace.garbage_collect + ObjectSpace.garbage_collect p foo.to_s # should raise exception (recycled) end |
