From 39d79b5b02bfa183715996b15e7b3ca2b87973b9 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sun, 14 Nov 2010 20:16:46 +0100 Subject: Smoother reload Let's not wait for active connections to clear their queue when we're shutting down the REPL. --- elisp/geiser-connection.el | 48 ++++++++++++++++++---------------------------- elisp/geiser-repl.el | 2 +- 2 files changed, 20 insertions(+), 30 deletions(-) (limited to 'elisp') 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)) -- cgit v1.2.3