changelog shortlog graph tags branches changeset files revisions annotate raw help

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

changeset 691: 295ea43ceb2d
parent: 8b10eabe89dd
child: f51b73f49946
author: Richard Westhaver <ellis@rwest.io>
date: Wed, 02 Oct 2024 23:39:07 -0400
permissions: -rw-r--r--
description: tasks
1 ;;; tests/task.lisp --- Task Tests
2 
3 ;;
4 
5 ;;; Code:
6 (in-package :std/tests)
7 (in-suite :std)
8 
9 (deftest tasks ()
10  "Test task-pools, oracles, and workers."
11  (with-threads (4 :args (&optional (a 0) (b 1) (c 2)))
12  (is (= 3 (+ a b c))))
13  ;; *ORACLE-THREADS* contains the *CURRENT-THREAD*.
14  (std/task:with-task-pool (tp :count 10 :spawn 4)
15  (is (= 4 (length (task-pool-workers tp))))
16  (std/task::task-pool-lock tp)
17  (is (= 4 (std/task::mailbox-count (task-pool-results tp))))
18  (describe tp)
19  (dotimes (i 4)
20  (is (eql t (std/task::receive-message (task-pool-results tp)))))
21  (is (null (std/task::receive-message-no-hang (task-pool-results tp))))))