From 2985bc43ff081d3708a48dfdf15d4456893365ab Mon Sep 17 00:00:00 2001 From: Manfred Bergmann Date: Mon, 1 Jul 2024 19:22:08 +0200 Subject: [PATCH] fixed bounded-queue full check (#86). added bounded-queue tests. --- sento.asd | 3 ++- src/queue/queue.lisp | 4 ++-- tests/actor-test.lisp | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sento.asd b/sento.asd index 9bf2277..4f25771 100644 --- a/sento.asd +++ b/sento.asd @@ -1,5 +1,5 @@ (defsystem "sento" - :version "3.1.1" + :version "3.3.0" :author "Manfred Bergmann" :license "Apache-2" :description "Actor framework featuring actors and agents for easy access to state and asynchronous operations." @@ -73,6 +73,7 @@ (:file "config-test") (:file "wheel-timer-test") (:file "timeutils-test") + (:file "bounded-queue-test") (:file "actor-cell-test") (:file "actor-mp-test") (:file "agent-test") diff --git a/src/queue/queue.lisp b/src/queue/queue.lisp index 7f26763..e4081b6 100644 --- a/src/queue/queue.lisp +++ b/src/queue/queue.lisp @@ -56,9 +56,9 @@ (defmethod pushq ((self queue-bounded) element) (with-slots (queue lock cvar fill-count max-items) self - (when (>= fill-count max-items) - (error 'queue-full-error :queue self)) (bt2:with-lock-held (lock) + (when (>= fill-count max-items) + (error 'queue-full-error :queue self)) (cl-speedy-queue:enqueue element queue) (incf fill-count) (bt2:condition-notify cvar)))) diff --git a/tests/actor-test.lisp b/tests/actor-test.lisp index 9e9ad99..890cdeb 100644 --- a/tests/actor-test.lisp +++ b/tests/actor-test.lisp @@ -3,7 +3,8 @@ (:shadow #:! #:?) (:import-from #:miscutils #:assert-cond - #:await-cond) + #:await-cond + #:filter) (:import-from #:timeutils #:ask-timeout) (:import-from #:ac @@ -513,6 +514,6 @@ (loop :repeat 10 :collect (ignore-errors (tell actor "run"))))) - (is (= 1 (length (mapcan (lambda (x) (if x (list x))) tells)))) - (is (= 9 (length (mapcan (lambda (x) (if (null x) (list x))) tells))))) + (is (= 1 (length (filter (lambda (x) (if x x)) tells)))) + (is (= 9 (length (filter #'null tells))))) (ac:shutdown sys))))