From: Javier Sancho Date: Sun, 3 Nov 2013 14:42:25 +0000 (+0100) Subject: Improving with-engine X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=2a4f421a74b6e31e7718d206be704f1d42a268a2;p=gacela.git Improving with-engine * src/engine.scm: with-engine now saves current engine for recursive calls and uses engine mutex for exclusive access --- diff --git a/src/engine.scm b/src/engine.scm index 6d5e0e7..0770e09 100644 --- a/src/engine.scm +++ b/src/engine.scm @@ -94,10 +94,12 @@ (define-syntax with-engine (syntax-rules () ((_ engine body ...) - (begin + (let ((old-engine (current-engine))) (set-current-engine! engine) - (let ((res (begin body ...))) - (set-current-engine! #f) + (let ((res (with-mutex (engine-mutex engine) + body + ...))) + (set-current-engine! old-engine) res))))) (export current-engine