Finalizers

[email protected]$G$9!#e(B

ObjectSpace::{add,remove,call}_finalizere$B$Oe(Bdeprecatede$B$H7Y9p$,=P$ke(B
e$B$h$&$K$J$C$F$+$i$b$&D9$$$3$H7P$A$^$9!#$=$m$=$m>C$7$F$b$$$$$s$8$ce(B
e$B$J$$$G$7$g$&$+!#e(B

Index: gc.c

— gc.c (revision 15981)
+++ gc.c (working copy)
@@ -1861,55 +1861,4 @@ os_each_obj(int argc, VALUE *argv, VALUE
}

-static VALUE finalizers;

-/* deprecated

  • */

-static VALUE
-add_final(VALUE os, VALUE block)
-{

  • rb_warn(“ObjectSpace::add_finalizer is deprecated; use
    define_finalizer”);
  • if (!rb_respond_to(block, rb_intern(“call”))) {
  • rb_raise(rb_eArgError, “wrong type argument %s (should be callable)”,
  • rb_obj_classname(block));
    
  • }
  • rb_ary_push(finalizers, block);
  • return block;
    -}

-/*

    • deprecated
  • */
    -static VALUE
    -rm_final(VALUE os, VALUE block)
    -{
  • rb_warn(“ObjectSpace::remove_finalizer is deprecated; use
    undefine_finalizer”);
  • rb_ary_delete(finalizers, block);
  • return block;
    -}

-/*

    • deprecated
  • */
    -static VALUE
    -finals(void)
    -{
  • rb_warn(“ObjectSpace::finalizers is deprecated”);
  • return finalizers;
    -}

-/*

    • deprecated
  • */

-static VALUE
-call_final(VALUE os, VALUE obj)
-{

  • rb_warn(“ObjectSpace::call_finalizer is deprecated; use
    define_finalizer”);
  • need_call_final = 1;
  • FL_SET(obj, FL_FINALIZE);
  • return obj;
    -}

/*

  • call-seq:
    @@ -1999,12 +1948,5 @@ run_final(VALUE obj)
    rb_thread_critical = Qtrue;
    args[1] = 0;
  • if (RARRAY_LEN(finalizers) > 0) {

  • args[1] = rb_obj_freeze(rb_ary_new3(1, objid));

  • }
    args[2] = (VALUE)rb_safe_level();

  • for (i=0; i<RARRAY_LEN(finalizers); i++) {

  • args[0] = RARRAY_PTR(finalizers)[i];

  • rb_protect(run_single_final, (VALUE)args, &status);

  • }
    if (finalizer_table && st_delete(finalizer_table, (st_data_t*)&obj,
    &table)) {
    if (!args[1] && RARRAY_LEN(table) > 0) {
    @@ -2321,8 +2263,4 @@ Init_GC(void)
    rb_define_module_function(rb_mObSpace, “each_object”, os_each_obj,
    -1);
    rb_define_module_function(rb_mObSpace, “garbage_collect”,
    rb_gc_start, 0);

  • rb_define_module_function(rb_mObSpace, “add_finalizer”, add_final,
    1);

  • rb_define_module_function(rb_mObSpace, “remove_finalizer”,
    rm_final, 1);

  • rb_define_module_function(rb_mObSpace, “finalizers”, finals, 0);

  • rb_define_module_function(rb_mObSpace, “call_finalizer”,
    call_final, 1);

    rb_define_module_function(rb_mObSpace, “define_finalizer”,
    define_final, -1);
    @@ -2331,9 +2269,4 @@ Init_GC(void)
    rb_define_module_function(rb_mObSpace, “_id2ref”, id2ref, 1);

  • rb_gc_register_address(&rb_mObSpace);

  • rb_global_variable(&finalizers);

  • rb_gc_unregister_address(&rb_mObSpace);

  • finalizers = rb_ary_new();

  • source_filenames = st_init_strtable();

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:34349] finalizers”
on Sat, 12 Apr 2008 13:11:00 +0900, Nobuyoshi N.
[email protected] writes:

|ObjectSpace::{add,remove,call}_finalizere$B$Oe(Bdeprecatede$B$H7Y9p$,=P$ke(B
|e$B$h$&$K$J$C$F$+$i$b$&D9$$$3$H7P$A$^$9!#$=$m$=$m>C$7$F$b$$$$$s$8$ce(B
|e$B$J$$$G$7$g$&$+!#e(B

e$B$$$$$s$8$c$J$$$G$7$g$&$+!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs