summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--2d/game-loop.scm32
-rw-r--r--2d/repl/repl.scm9
2 files changed, 9 insertions, 32 deletions
diff --git a/2d/game-loop.scm b/2d/game-loop.scm
index 6f80297..844ddb5 100644
--- a/2d/game-loop.scm
+++ b/2d/game-loop.scm
@@ -32,8 +32,7 @@
#:use-module (2d repl server)
#:use-module (2d repl repl)
#:use-module (2d mvars)
- #:export (game-mvar
- on-active-hook
+ #:export (on-active-hook
on-resize-hook
on-quit-hook
on-render-hook
@@ -58,29 +57,6 @@
;;;
(define *fps* 0)
-(define game-mvar (new-mvar))
-
-;; The REPL sets this flag when it needs to evaluate something.
-;; Only the REPL server thread will mutate this variable.
-;;(define *repl-waiting* #f)
-;;(define game-loop-mutex (make-mutex 'unchecked-unlock))
-
-;;;
-;;; REPL Hooks
-;;;
-
-;; Lock game loop mutex before evaluating code from REPL server and
-;; unlock it afterwards.
-;; (add-hook! before-eval-hook
-;; (lambda (exp)
-;; (set! *repl-waiting* #t)
-;; (lock-mutex game-loop-mutex)))
-
-;; (add-hook! after-eval-hook
-;; (lambda (exp)
-;; (set! *repl-waiting* #f)
-;; (when (equal? (mutex-owner game-loop-mutex) (current-thread))
-;; (unlock-mutex game-loop-mutex))))
;;;
;;; Hooks
@@ -198,7 +174,7 @@ is the unused accumulator time."
(define (run-repl-thunk thunk input output error)
(put-mvar
- game-mvar
+ repl-output-mvar
(with-input-from-port input
(lambda ()
(with-output-to-port output
@@ -207,8 +183,8 @@ is the unused accumulator time."
(define (run-repl)
"Execute a thunk from the REPL is there is one."
- (unless (mvar-empty? repl-mvar)
- (and-let* ((vals (try-take-mvar repl-mvar)))
+ (unless (mvar-empty? repl-input-mvar)
+ (and-let* ((vals (try-take-mvar repl-input-mvar)))
(apply run-repl-thunk vals))))
;;;
diff --git a/2d/repl/repl.scm b/2d/repl/repl.scm
index a5b0536..58b79e3 100644
--- a/2d/repl/repl.scm
+++ b/2d/repl/repl.scm
@@ -31,7 +31,7 @@
#:use-module (ice-9 control)
#:use-module (2d mvars)
#:use-module (2d game-loop)
- #:export (repl-mvar start-repl run-repl))
+ #:export (repl-input-mvar repl-output-mvar start-repl run-repl))
;;;
@@ -130,7 +130,8 @@
;;; The repl
;;;
-(define repl-mvar (new-mvar))
+(define repl-input-mvar (new-mvar))
+(define repl-output-mvar (new-mvar))
(define* (start-repl #:optional (lang (current-language)) #:key debug)
;; ,language at the REPL will update the current-language. Make
@@ -196,7 +197,7 @@
;; game loop will schedule it and run
;; it on the next tick.
(put-mvar
- repl-mvar
+ repl-input-mvar
(list
(lambda ()
(call-with-error-handling
@@ -209,7 +210,7 @@
;; Read the results back from
;; game-mvar. Will block until results
;; are available.
- (take-mvar game-mvar))
+ (take-mvar repl-output-mvar))
(lambda (k) (values))))
(lambda l
(for-each (lambda (v)