Changeset 13250


Ignore:
Timestamp:
03/13/11 19:55:52 (11 years ago)
Author:
ehuelsmann
Message:

Close #138 by implementing a general post-finalization notification mechanism.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/Autoload.java

    r13249 r13250  
    520520        autoload(PACKAGE_EXT, "make-weak-reference", "WeakReference", true);
    521521        autoload(PACKAGE_EXT, "weak-reference-value", "WeakReference", true);
     522        autoload(PACKAGE_EXT, "finalize", "Primitives", true);
     523        autoload(PACKAGE_EXT, "cancel-finalization", "Primitives", true);
    522524        autoload(PACKAGE_JAVA, "%jnew-proxy", "JProxy");
    523525        autoload(PACKAGE_JAVA, "%find-java-class", "JavaObject");
  • trunk/abcl/src/org/armedbear/lisp/Primitives.java

    r13249 r13250  
    33 *
    44 * Copyright (C) 2002-2007 Peter Graves
     5 * Copyright (C) 2011 Erik Huelsmann
    56 * $Id$
    67 *
     
    3839import java.math.BigInteger;
    3940import java.util.ArrayList;
     41import org.armedbear.lisp.util.Finalizer;
    4042
    4143public final class Primitives {
     
    58195821    };
    58205822
     5823    // ### finalize
     5824    private static final Primitive FINALIZE
     5825        = new pf_finalize();
     5826    private static final class pf_finalize extends Primitive {
     5827        pf_finalize() {
     5828            super("finalize", PACKAGE_EXT, true, "object function");
     5829        }
     5830
     5831        @Override
     5832        public LispObject execute(LispObject obj, final LispObject fun) {
     5833            Finalizer.addFinalizer(obj, new Runnable() {
     5834                @Override
     5835                public void run() {
     5836                    fun.execute();
     5837                }
     5838            });
     5839            return obj;
     5840        }
     5841    };
     5842
     5843    // ### cancel-finalization
     5844    private static final Primitive CANCEL_FINALIZATION
     5845        = new pf_cancel_finalization();
     5846    private static final class pf_cancel_finalization extends Primitive {
     5847        pf_cancel_finalization() {
     5848            super("cancel-finalization", PACKAGE_EXT, true, "object");
     5849        }
     5850
     5851        @Override
     5852        public LispObject execute(LispObject obj) {
     5853            Finalizer.clearFinalizers(obj);
     5854            return obj;
     5855        }
     5856    };
     5857
    58215858}
Note: See TracChangeset for help on using the changeset viewer.