~ chicken-core (chicken-5) 323994049d6f7713faa414c7315ec24d3240d1f7
commit 323994049d6f7713faa414c7315ec24d3240d1f7
Author: felix.winkelmann@bevuta.com <felix.winkelmann@bevuta.com>
AuthorDate: Thu Apr 30 17:08:35 2020 +0200
Commit: Kooda <kooda@upyum.com>
CommitDate: Tue Jul 28 13:19:33 2020 +0200
Only force finalizers at program cleanup when live finalizer count is non-zero
Signed-off-by: Kooda <kooda@upyum.com>
diff --git a/NEWS b/NEWS
index e5372080..7164df42 100644
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,8 @@
deprecation of current-milliseconds.
- Officially deprecated C_pair() in favor of C_a_pair(); it has
been deprecated for years.
+ - At program cleanup, finalizers are only forced when the live
+ finalizer count is non-zero
- Build system
- Auto-configure at build time on most platforms. Cross-compilation
diff --git a/library.scm b/library.scm
index 1a7e48f2..c5015b7a 100644
--- a/library.scm
+++ b/library.scm
@@ -5008,10 +5008,13 @@ EOF
(unless (null? tasks)
(for-each (lambda (t) (t)) tasks)
(loop))))
- (when (##sys#debug-mode?)
- (##sys#print "[debug] forcing finalizers...\n" #f ##sys#standard-error))
- (when (chicken.gc#force-finalizers)
- (##sys#force-finalizers)))
+ (when (fx> (##sys#slot ##sys#pending-finalizers 0) 0)
+ (##sys#run-pending-finalizers #f))
+ (when (fx> (##core#inline "C_i_live_finalizer_count") 0)
+ (when (##sys#debug-mode?)
+ (##sys#print "[debug] forcing finalizers...\n" #f ##sys#standard-error))
+ (when (chicken.gc#force-finalizers)
+ (##sys#force-finalizers))))
(set! chicken.base#exit-handler
(make-parameter
Trap