From c23b31bdc0acd94adcbf5c4bb87b0022b0591959 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 17 Feb 2014 14:39:59 -0500 Subject: Rewrite define-guardian to avoid 'after-cg-hook'. * 2d/helpers.scm (define-guardian): Don't use 'after-gc-hook'. --- 2d/helpers.scm | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to '2d') diff --git a/2d/helpers.scm b/2d/helpers.scm index a9d2dfe..6106d90 100644 --- a/2d/helpers.scm +++ b/2d/helpers.scm @@ -45,14 +45,10 @@ within the guardian is GC'd. Reaping is ensured to happen from the same thread that is running the game loop." (begin (define name (make-guardian)) - (add-hook! after-gc-hook - (lambda () - (define (reap) - (let ((obj (name))) - (when obj - (reaper obj) - (reap)))) - ;; Scheduling the reaping procedure in the game - ;; loop's agenda ensures that the reaping will be - ;; done in the main thread. - (schedule game-agenda reap))))) + (schedule-interval game-agenda + (lambda () + (let reap ((obj (name))) + (when obj + (reaper obj) + (reap (name))))) + 1))) -- cgit v1.2.3