From 9c937ea2c27049580a7461309b5f9c3e880187c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20March=C3=A1n?= Date: Mon, 19 Oct 2009 22:19:01 -0500 Subject: [PATCH] SELECT: More tweaking. This is clearly wrong and won't work. Mining for ideas. --- src/channels.lisp | 12 ++++++++---- src/select.lisp | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/channels.lisp b/src/channels.lisp index fa7b7f6..6fbdb1f 100644 --- a/src/channels.lisp +++ b/src/channels.lisp @@ -9,6 +9,8 @@ (defvar *select-cond-var* nil "Used by select, signaled by channels.x") +(defvar *select-can-continue* nil) + ;;; ;;; Abstract channel interface ;;; @@ -87,8 +89,9 @@ blocking (if it would block)")) do (bt:condition-wait (channel-send-ok channel) lock) else do (return-from send nil))) (bt:condition-notify recv-ok) - (when *select-cond-var* - (bt:condition-notify *select-cond-var*)) + (when (and *select-cond-var* (boundp *select-can-continue*)) + (bt:condition-notify *select-cond-var*) + (setf *select-can-continue* t)) (let ((block-status (channel-being-read-p channel))) (channel-insert-value channel value) (when block-status @@ -118,8 +121,9 @@ interactive/debugging purposes.")) (bt:with-recursive-lock-held (lock) (with-read-state channel (bt:condition-notify send-ok) - (when *select-cond-var* - (bt:condition-notify *select-cond-var*)) + (when (and *select-cond-var* (boundp *select-can-continue*)) + (bt:condition-notify *select-cond-var*) + (setf *select-can-continue* t)) (loop while (recv-blocks-p channel) do (if (or blockp (channel-being-written-p channel)) (bt:condition-wait (channel-recv-ok channel) lock) diff --git a/src/select.lisp b/src/select.lisp index 5cd9abb..2006928 100644 --- a/src/select.lisp +++ b/src/select.lisp @@ -44,6 +44,7 @@ reserved for individual SELECT clauses." `(block nil ;; todo - make SELECT pause for *select-cond-var* (let ((*select-cond-var* (bt:make-condition-variable)) + *select-can-continue* (,lock (bt:make-lock))) (bt:with-lock-held (,lock) ,(if (null main-clauses) @@ -69,7 +70,8 @@ reserved for individual SELECT clauses." (wrap-select-clause else-clause) `(progn (setf ,repeat-counter ,num-clauses) - (bt:condition-wait *select-cond-var* ,lock) + (loop until *select-can-continue* + do (bt:condition-wait *select-cond-var* ,lock)) (go ,pick-clause))))))))))))) (defun clause-type (clause)