Skip to content

Commit

Permalink
fixed bounded-queue full check (#86). added bounded-queue tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdbergmann committed Jul 1, 2024
1 parent 72b042e commit 2985bc4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion sento.asd
Original file line number Diff line number Diff line change
@@ -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."
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions src/queue/queue.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand Down
7 changes: 4 additions & 3 deletions tests/actor-test.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
(:shadow #:! #:?)
(:import-from #:miscutils
#:assert-cond
#:await-cond)
#:await-cond
#:filter)
(:import-from #:timeutils
#:ask-timeout)
(:import-from #:ac
Expand Down Expand Up @@ -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))))

0 comments on commit 2985bc4

Please sign in to comment.