changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / lisp/std/tests/task.lisp

changeset 692: f51b73f49946
parent: 295ea43ceb2d
child: a36280d2ef4e
author: Richard Westhaver <ellis@rwest.io>
date: Thu, 03 Oct 2024 17:56:11 -0400
permissions: -rw-r--r--
description: std/task and tests
1 ;;; tests/task.lisp --- Task Tests
2 
3 ;;
4 
5 ;;; Code:
6 (in-package :std/tests)
7 (in-suite :std)
8 
9 (deftest task-pool ()
10  "Task Pool tests."
11  (with-task-pool (tp :workers 4 :tasks 10 :start t)
12  (is (= 4 (length (task-pool-workers tp))))
13  (is (> (std/task::mailbox-count (task-pool-results tp)) 0))
14  (dotimes (i 4)
15  (is (null (std/task::receive-message (task-pool-results tp)))))
16  (is (null (std/task::receive-message-no-hang (task-pool-results tp))))
17  (kill-workers tp)
18  (is (zerop (worker-count tp))))
19  (with-task-pool (tp :workers 4 :tasks 4 :start nil)
20  (is (zerop (sb-concurrency:mailbox-count (results tp))))
21  (start-task-workers tp)
22  (loop for w across (workers tp)
23  do (join-worker w))
24  (is (= 4 (sb-concurrency:mailbox-count (results tp))))))
25