27 Jul 12:42
Suggested patch for Open Dylan's C runtime
From: Thomas Christian Chust <chust <at> web.de>
Subject: Suggested patch for Open Dylan's C runtime
Newsgroups: gmane.comp.lang.dylan.gwydion.devel
Date: 2007-07-27 10:42:37 GMT
Subject: Suggested patch for Open Dylan's C runtime
Newsgroups: gmane.comp.lang.dylan.gwydion.devel
Date: 2007-07-27 10:42:37 GMT
Hello,
the current 1.0beta4 version of Open Dylan doesn't support finalizers
for objects in programs built with the C runtime that uses the
Boehm-Demers-Weiser garbage collector.
However, I think it is pretty easy to add that feature. I have tested
the attached patch for opendylan/sources/dfmc/c-run-time/run-time.{h,c}
on my PowerPC MacOS X installation of Open Dylan and it seems to work
just fine.
cu,
Thomas
--- _run-time.h 2007-07-26 20:34:57.000000000 +0200
+++ run-time.h 2007-07-26 20:44:01.000000000 +0200
@@ -1044,8 +1044,8 @@
#define primitive_gc_state() (I(0)) /* !@#$ DUMMY DEFN */
#define primitive_pin_object(x) (x)
extern void primitive_unpin_object(D);
-#define primitive_mps_finalize(x) { }
-#define primitive_mps_finalization_queue_first() ((D)0)
+extern void primitive_mps_finalize(D);
+extern void* primitive_mps_finalization_queue_first();
#define primitive_mps_park()
#define primitive_mps_clamp()
#define primitive_mps_release()
--- _run-time.c 2007-07-26 20:34:46.000000000 +0200
(Continue reading)
> In fact if you want to guaranteed that finalizers will be run before
> program exit then you have to do that anyway. Then you'll have the
> actual finalizer remove the object from the program exit cleanup list.
The way finalization is implemented in Open Dylan, finalizers are not
guaranteed to be run on program exit, I think.
> You can also use the facility in Boehm for asynchronous finalization
> using the GC_invoke_finalizers() function and either setting your own
> function into the GC_finalizer_notifier variable or else polling
> GC_should_invoke_finalizers(). So you can for example set
> GC_finalizer_notifier to point to a function that clears a semaphore
> that releases a thread that calls GC_invoke_finalizers(). No need to
> keep track of anything else yourself. The GC won't delete the objects
RSS Feed