diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-11-14 20:16:46 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-11-14 20:16:46 +0100 |
commit | 39d79b5b02bfa183715996b15e7b3ca2b87973b9 (patch) | |
tree | 2a7b7dfe97ef9fe0652777ccd50c46e40f849e96 | |
parent | 579bf848c75cb2f4920227c2ac2a4535eb676eca (diff) | |
download | geiser-guile-39d79b5b02bfa183715996b15e7b3ca2b87973b9.tar.gz geiser-guile-39d79b5b02bfa183715996b15e7b3ca2b87973b9.tar.bz2 |
Smoother reload
Let's not wait for active connections to clear their queue when we're
shutting down the REPL.
-rw-r--r-- | elisp/geiser-connection.el | 48 | ||||
-rw-r--r-- | elisp/geiser-repl.el | 2 |
2 files changed, 20 insertions, 30 deletions
diff --git a/elisp/geiser-connection.el b/elisp/geiser-connection.el index d41110c..509bdf0 100644 --- a/elisp/geiser-connection.el +++ b/elisp/geiser-connection.el @@ -84,25 +84,6 @@ (cons :count 0) (cons :completed (make-hash-table :weakness 'value)))) -(defun geiser-con--connection-deactivate (c) - (when (car c) - (let* ((tq (geiser-con--connection-tq c)) - (proc (geiser-con--connection-process c)) - (proc-filter (geiser-con--connection-filter c))) - (while (not (tq-queue-empty tq)) - (accept-process-output proc 0.1)) - (set-process-filter proc proc-filter) - (setcar c nil)))) - -(defun geiser-con--connection-activate (c) - (when (not (car c)) - (let* ((tq (geiser-con--connection-tq c)) - (proc (geiser-con--connection-process c)) - (tq-filter (geiser-con--connection-tq-filter c))) - (while (accept-process-output proc 0.01)) - (set-process-filter proc tq-filter) - (setcar c t)))) - (defsubst geiser-con--connection-process (c) (tq-process (cdr (assoc :tq c)))) @@ -151,16 +132,25 @@ (concat geiser-con--startup-prompt s)) nil) -(defun geiser-con--open-connection (host port prompt debug-prompt) - (setq geiser-con--startup-prompt "") - (let* ((name (format "geiser-con@%s:%s" host port)) - (proc (open-network-stream name nil host port))) - (set-process-filter proc 'geiser-con--startup-prompt) - (with-timeout (10 - (error (format "Timeout connecting to %s:%s" host port))) - (while (not (string-match prompt geiser-con--startup-prompt)) - (accept-process-output proc 0.05))) - (geiser-con--make-connection proc prompt debug-prompt))) +(defun geiser-con--connection-deactivate (c &optional no-wait) + (when (car c) + (let* ((tq (geiser-con--connection-tq c)) + (proc (geiser-con--connection-process c)) + (proc-filter (geiser-con--connection-filter c))) + (unless no-wait + (while (and (not (tq-queue-empty tq)) + (accept-process-output proc 0.1)))) + (set-process-filter proc proc-filter) + (setcar c nil)))) + +(defun geiser-con--connection-activate (c) + (when (not (car c)) + (let* ((tq (geiser-con--connection-tq c)) + (proc (geiser-con--connection-process c)) + (tq-filter (geiser-con--connection-tq-filter c))) + (while (accept-process-output proc 0.01)) + (set-process-filter proc tq-filter) + (setcar c t)))) ;;; Requests handling: diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el index 070a108..8c51818 100644 --- a/elisp/geiser-repl.el +++ b/elisp/geiser-repl.el @@ -340,7 +340,7 @@ module command as a string") (let ((cb (current-buffer)) (impl geiser-impl--implementation) (comint-prompt-read-only nil)) - (geiser-con--connection-deactivate geiser-repl--connection) + (geiser-con--connection-deactivate geiser-repl--connection t) (geiser-con--connection-close geiser-repl--connection) (setq geiser-repl--repls (remove cb geiser-repl--repls)) (dolist (buffer (buffer-list)) |