fix the way we break from the main loop

This commit is contained in:
Renaud Casenave-Péré 2014-08-13 18:14:18 +09:00
parent a10a88f6bc
commit 246668c4cc

View file

@ -10,21 +10,22 @@
(:export :main :quit))
(in-package :stoe)
(defun main-loop (&optional unprotected)
"Run the protected main-loop. An error will be catched with the possibility to
(let ((exit-main-loop nil))
(defun main-loop (&optional unprotected)
"Run the protected main-loop. An error will be catched with the possibility to
continue unless `unprotected' is t."
(let ((clock (make-clock)))
(catch 'exit-main-loop
(loop (restartable unprotected
(update-current-time)
(update-clock clock (get-delta-time))
(modules:update (clock-delta clock))
(eval-repl)
(sleep 0.01))))))
(setf exit-main-loop nil)
(let ((clock (make-clock)))
(loop while (not exit-main-loop)
do (restartable unprotected
(update-current-time)
(update-clock clock (get-delta-time))
(modules:update (clock-delta clock))
(sleep 0.01)))))
(defun quit ()
"Quit the main loop."
(throw 'exit-main-loop nil))
(defun quit ()
"Quit the main loop."
(setf exit-main-loop t)))
(defun main (&optional argv)
"Run the program."