test event loop in background
src/repl.lisp
Sat Jun 6 17:07:40 CEST 2009 Tobias Rautenkranz <tobias@rautenkranz.ch>
* test event loop in background
--- old-repl/src/repl.lisp 2014-10-30 08:03:58.000000000 +0100
+++ new-repl/src/repl.lisp 2014-10-30 08:03:58.000000000 +0100
@@ -26,6 +26,7 @@
(values-list (result *qt-eval*)))
(defun end-event-loop ()
+ #+slime
(setf (fdefinition 'swank::eval-region)
#'(lambda (string)
(with-input-from-string (stream string)
@@ -45,6 +46,7 @@
"Starts the QApplication event loop in a new thread and
sends the forms entered at the REPL to this thread to be evaluated."
;; Like eval-region of Slimes swank.lisp
+ #+slime
(setf (fdefinition 'swank::eval-region)
#'(lambda (string)
(with-input-from-string (stream string)
@@ -64,8 +66,11 @@
(trace-output *trace-output*)
(error-output *error-output*)
(query-io *query-io*)
- (terminal-io *terminal-io*))
+ (terminal-io *terminal-io*)
+ (ready-lock (bt:make-lock))
+ (ready (bt:make-condition-variable)))
(bt:make-thread #'(lambda ()
+ #+slime
(setf *standard-input* standard-input
*standard-output* standard-output
*debug-io* debug-io
@@ -76,11 +81,14 @@
(qt:with-app
(qt:application.set-quit-on-last-window-closed nil)
(setf *qt-eval* (make-instance 'qt-eval))
- (format t "exec~%")
- (qt:exec)
- (format t "exec-done~%")))
- :name "Qt Event Loop")))
+ (qt:do-delayed-initialize
+ (bt:condition-notify ready))
+ (qt:exec)))
+ :name "Qt Event Loop")
+ (bt:with-lock-held (ready-lock)
+ (bt:condition-wait ready ready-lock))))
+#+slime
(defun start-event-loop-in-repl ()
"Start the QApplication event loop in the current REPL thread.
When idle the event loop updates the REPL.