return 1;
}
-/* Finalizer proc support */
-static void (*GC_object_finalized_proc) (GC_PTR obj);
+/* Finalizer callback support. */
+STATIC GC_await_finalize_proc GC_object_finalized_proc = 0;
-void
-GC_set_finalizer_notify_proc (void (*proc) (GC_PTR obj))
+GC_API void GC_CALL GC_set_await_finalize_proc(GC_await_finalize_proc fn)
{
- GC_object_finalized_proc = proc;
+ DCL_LOCK_STATE;
+
+ LOCK();
+ GC_object_finalized_proc = fn;
+ UNLOCK();
+}
+
+GC_API GC_await_finalize_proc GC_CALL GC_get_await_finalize_proc(void)
+{
+ GC_await_finalize_proc fn;
+ DCL_LOCK_STATE;
+
+ LOCK();
+ fn = GC_object_finalized_proc;
+ UNLOCK();
+ return fn;
}
#ifndef GC_LONG_REFS_NOT_NEEDED
fo_set_next(prev_fo, next_fo);
}
GC_fo_entries--;
-
if (GC_object_finalized_proc)
- GC_object_finalized_proc (real_ptr);
+ GC_object_finalized_proc(real_ptr);
/* Add to list of objects awaiting finalization. */
fo_set_next(curr_fo, GC_finalize_now);
/* Similar to GC_unregister_disappearing_link but for a */
/* registration by either of the above two routines. */
-/* finalizer callback support */
-GC_API void GC_set_finalizer_notify_proc GC_PROTO((void (*object_finalized) (GC_PTR obj)));
+/* Finalizer callback support. Invoked by the collector (with */
+/* the allocation lock held) for each unreachable object */
+/* enqueued for finalization. */
+typedef void (GC_CALLBACK * GC_await_finalize_proc)(void * /* obj */);
+GC_API void GC_CALL GC_set_await_finalize_proc(GC_await_finalize_proc);
+GC_API GC_await_finalize_proc GC_CALL GC_get_await_finalize_proc(void);
+ /* Zero means no callback. The setter */
+ /* and getter acquire the lock too. */
/* Returns !=0 if GC_invoke_finalizers has something to do. */
GC_API int GC_CALL GC_should_invoke_finalizers(void);