45 lines
807 B
Scheme
45 lines
807 B
Scheme
|
(use-modules (tests)
|
||
|
(srfi srfi-71)
|
||
|
(fibers)
|
||
|
(unit-test)
|
||
|
(knots thread-pool))
|
||
|
|
||
|
(let ((thread-pool
|
||
|
(make-thread-pool 2)))
|
||
|
|
||
|
(run-fibers-for-tests
|
||
|
(lambda ()
|
||
|
(assert-equal
|
||
|
(call-with-thread
|
||
|
thread-pool
|
||
|
(lambda ()
|
||
|
4))
|
||
|
4))))
|
||
|
|
||
|
(let ((thread-pool
|
||
|
(make-thread-pool
|
||
|
2
|
||
|
#:thread-initializer (const '(2)))))
|
||
|
|
||
|
(run-fibers-for-tests
|
||
|
(lambda ()
|
||
|
(assert-equal
|
||
|
(call-with-thread
|
||
|
thread-pool
|
||
|
(lambda (num)
|
||
|
(* 2 num)))
|
||
|
4))))
|
||
|
|
||
|
(let ((process-job
|
||
|
count-jobs
|
||
|
count-threads
|
||
|
list-jobs
|
||
|
(create-work-queue
|
||
|
2
|
||
|
(lambda (i)
|
||
|
(* i 2)))))
|
||
|
|
||
|
(process-job 3))
|
||
|
|
||
|
(display "thread-pool test finished successfully\n")
|