From 7946d2357af1a142d7490a05f7f33531a3f28e81 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 19 Jun 2005 17:16:14 +0000 Subject: * gc.c (define_final): document fix: finalizers never get called before target object is destroyed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 ++++++-- gc.c | 74 +++++++++++++++++++++++++++++++-------------------------------- 2 files changed, 44 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index 829c82af27..601e5d459c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Jun 20 02:15:35 2005 Nobuyoshi Nakada + + * gc.c (define_final): document fix: finalizers never get called + before target object is destroyed. + Mon Jun 20 01:26:49 2005 GOTOU Yuuzou * ext/openssl/openssl_missing.c, ext/openssl/ossl.h, @@ -8,8 +13,8 @@ Mon Jun 20 01:26:49 2005 GOTOU Yuuzou Sun Jun 19 17:22:02 CEST 2005 Michael Neumann * lib/xmlrpc/utils.rb: Patch by Nobuhiro IMAI fixes the following - problem: Default value modification on - Module#public_instance_methods (false -> true) breaks + problem: Default value modification on + Module#public_instance_methods (false -> true) breaks s.add_handler(XMLRPC::iPIMethods("sample"), MyHandler.new) style security protection. diff --git a/gc.c b/gc.c index 04b8b4a802..2e7bdca5dd 100644 --- a/gc.c +++ b/gc.c @@ -187,14 +187,14 @@ static st_table *finalizer_table = 0; /* * call-seq: * GC.enable => true or false - * + * * Enables garbage collection, returning true if garbage * collection was previously disabled. - * + * * GC.disable #=> false * GC.enable #=> true * GC.enable #=> false - * + * */ VALUE @@ -209,13 +209,13 @@ rb_gc_enable() /* * call-seq: * GC.disable => true or false - * + * * Disables garbage collection, returning true if garbage * collection was already disabled. - * + * * GC.disable #=> false * GC.disable #=> true - * + * */ VALUE @@ -298,7 +298,7 @@ typedef struct RVALUE { struct RFile file; struct RNode node; struct RMatch match; - struct RVarmap varmap; + struct RVarmap varmap; struct SCOPE scope; } as; #ifdef GC_DEBUG @@ -697,7 +697,7 @@ rb_gc_mark_maybe(obj) #define GC_LEVEL_MAX 250 -void +static void gc_mark(ptr, lev) VALUE ptr; int lev; @@ -707,7 +707,7 @@ gc_mark(ptr, lev) obj = RANY(ptr); if (rb_special_const_p(ptr)) return; /* special const not marked */ if (obj->as.basic.flags == 0) return; /* free cell */ - if (obj->as.basic.flags & FL_MARK) return; /* already marked */ + if (obj->as.basic.flags & FL_MARK) return; /* already marked */ obj->as.basic.flags |= FL_MARK; if (lev > GC_LEVEL_MAX || (lev == 0 && ruby_stack_check())) { @@ -745,7 +745,7 @@ gc_mark_children(ptr, lev) obj = RANY(ptr); if (rb_special_const_p(ptr)) return; /* special const not marked */ if (obj->as.basic.flags == 0) return; /* free cell */ - if (obj->as.basic.flags & FL_MARK) return; /* already marked */ + if (obj->as.basic.flags & FL_MARK) return; /* already marked */ obj->as.basic.flags |= FL_MARK; marking: @@ -1309,10 +1309,10 @@ garbage_collect() during_gc++; init_mark_stack(); - + /* mark frame stack */ for (frame = ruby_frame; frame; frame = frame->prev) { - rb_gc_mark_frame(frame); + rb_gc_mark_frame(frame); if (frame->tmp) { struct FRAME *tmp = frame->tmp; while (tmp) { @@ -1386,7 +1386,7 @@ garbage_collect() rb_mark_generic_ivar_tbl(); rb_gc_mark_parser(); - + /* gc_mark objects whose marking are not completed*/ while (!MARK_STACK_EMPTY){ if (mark_stack_overflow){ @@ -1413,7 +1413,7 @@ rb_gc() * ObjectSpace.garbage_collect => nil * * Initiates garbage collection, unless manually disabled. - * + * */ VALUE @@ -1479,29 +1479,29 @@ Init_stack(addr) * The ObjectSpace module contains a number of routines * that interact with the garbage collection facility and allow you to * traverse all living objects with an iterator. - * + * * ObjectSpace also provides support for object * finalizers, procs that will be called when a specific object is * about to be destroyed by garbage collection. - * + * * include ObjectSpace - * - * + * + * * a = "A" * b = "B" * c = "C" - * - * + * + * * define_finalizer(a, proc {|id| puts "Finalizer one on #{id}" }) * define_finalizer(a, proc {|id| puts "Finalizer two on #{id}" }) * define_finalizer(b, proc {|id| puts "Finalizer three on #{id}" }) - * + * * produces: - * + * * Finalizer three on 537763470 * Finalizer one on 537763480 * Finalizer two on 537763480 - * + * */ void @@ -1583,7 +1583,7 @@ os_obj_of(of) /* * call-seq: * ObjectSpace.each_object([module]) {|obj| ... } => fixnum - * + * * Calls the block once for each living, nonimmediate object in this * Ruby process. If module is specified, calls the block * for only those classes or modules that match (or are a subclass of) @@ -1593,15 +1593,15 @@ os_obj_of(of) * never returned. In the example below, each_object * returns both the numbers we defined and several constants defined in * the Math module. - * + * * a = 102.7 * b = 95 # Won't be returned * c = 12345678987654321 * count = ObjectSpace.each_object(Numeric) {|x| p x } * puts "Total count: #{count}" - * + * * produces: - * + * * 12345678987654321 * 102.7 * 2.71828182845905 @@ -1610,7 +1610,7 @@ os_obj_of(of) * 1.7976931348623157e+308 * 2.2250738585072e-308 * Total count: 7 - * + * */ static VALUE @@ -1686,9 +1686,9 @@ call_final(os, obj) /* * call-seq: * ObjectSpace.undefine_finalizer(obj) - * + * * Removes all finalizers for obj. - * + * */ static VALUE @@ -1704,10 +1704,10 @@ undefine_final(os, obj) /* * call-seq: * ObjectSpace.define_finalizer(obj, aProc=proc()) - * - * Adds aProc as a finalizer, to be called when obj - * is about to be destroyed. - * + * + * Adds aProc as a finalizer, to be called after obj + * was destroyed. + * */ static VALUE @@ -1857,14 +1857,14 @@ rb_gc_call_finalizer_at_exit() /* * call-seq: * ObjectSpace._id2ref(object_id) -> an_object - * + * * Converts an object id to a reference to the object. May not be * called on an object id passed as a parameter to a finalizer. - * + * * s = "I am a string" #=> "I am a string" * r = ObjectSpace._id2ref(s.object_id) #=> "I am a string" * r == s #=> true - * + * */ static VALUE -- cgit v1.2.3