(import testament :prefix "" :exit true) (import /src/threads) (defn thread-init [f] (thread/new (fn [parent] (f parent)))) (defn dist-job [i] (fn [parent] (:send parent [:res i true]))) (deftest distribute (let [jobs (seq [x :range [0 10]] (dist-job x)) out (threads/distribute jobs thread-init)] (is (== @{0 true 2 true 1 true 3 true 5 true 6 true 4 true 8 true 7 true 9 true} out)))) (defn pool-init [] ()) (defn do-work [parent self msg _state] (match msg :die (do (:send parent self) (thread/exit)) [:consume n] (spit (string "test/support/pool/" n) "ok"))) (deftest pool (os/shell "rm test/support/pool/*") (threads/demand-pipeline (range 0 10) pool-init do-work) # 10 + 1 placeholder file (is (= (length (os/dir "test/support/pool")) 11))) (run-tests!)