mirror of
https://github.com/janet-lang/janet
synced 2024-12-01 12:29:54 +00:00
5464a7a379
Makes ev/call less useful but ev/go more useful. No need to construct as many identical intermediate fibers.
23 lines
404 B
Plaintext
23 lines
404 B
Plaintext
(defn worker
|
|
"Run for a number of iterations."
|
|
[name iterations]
|
|
(for i 0 iterations
|
|
(ev/sleep 1)
|
|
(print "worker " name " iteration " i)))
|
|
|
|
(ev/call worker :a 10)
|
|
(ev/sleep 0.2)
|
|
(ev/call worker :b 5)
|
|
(ev/sleep 0.3)
|
|
(ev/call worker :c 12)
|
|
|
|
(defn worker2
|
|
[name]
|
|
(repeat 10
|
|
(ev/sleep 0.2)
|
|
(print name " working")))
|
|
|
|
(ev/go worker2 :bob)
|
|
(ev/go worker2 :joe)
|
|
(ev/go worker2 :sally)
|