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 | 162b48e1c36b523e3bdfcda20e25549ec3b342d1 (patch) | |
tree | 673631eb5dd71a6ce6ebc17b1287a7cddbfcc51b /elisp/geiser-connection.el | |
parent | 46270166e05946c6597f21f4e0083528ae53e4a5 (diff) | |
download | geiser-162b48e1c36b523e3bdfcda20e25549ec3b342d1.tar.gz geiser-162b48e1c36b523e3bdfcda20e25549ec3b342d1.tar.bz2 |
Smoother reload
Let's not wait for active connections to clear their queue when we're
shutting down the REPL.
Diffstat (limited to 'elisp/geiser-connection.el')
-rw-r--r-- | elisp/geiser-connection.el | 48 |
1 files changed, 19 insertions, 29 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: |