]> git.jsancho.org Git - gacela.git/commitdiff
Improving with-engine
authorJavier Sancho <jsf@jsancho.org>
Sun, 3 Nov 2013 14:42:25 +0000 (15:42 +0100)
committerJavier Sancho <jsf@jsancho.org>
Sun, 3 Nov 2013 14:42:25 +0000 (15:42 +0100)
* src/engine.scm: with-engine now saves current engine for recursive
                  calls and uses engine mutex for exclusive access

src/engine.scm

index 6d5e0e732ec23f56ba85b6e91253a0a88f08fea5..0770e09c217bc7446312c90db6ded657c794e14f 100644 (file)
 (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