aboutsummaryrefslogtreecommitdiff
path: root/tests/worker-threads.scm
blob: 72a56dc00167a250b5fe33a391f10e87cb89e973 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(use-modules (tests)
             (srfi srfi-71)
             (fibers)
             (unit-test)
             (knots worker-threads))

(let ((worker-thread-channel
       (make-worker-thread-channel
        (const '())
        #:parallelism 2)))

  (run-fibers-for-tests
   (lambda ()
     (assert-equal
      (call-with-worker-thread
       worker-thread-channel
       (lambda ()
         4))
      4))))

(let ((process-job
       count-jobs
       count-threads
       list-jobs
       (create-work-queue
        2
        (lambda (i)
          (* i 2)))))

  (process-job 3))

(display "worker-threads test finished successfully\n")