1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-05 08:16:16 +00:00
janet/examples/channel.janet
2020-08-01 13:13:58 -05:00

16 lines
311 B
Plaintext

(def c (ev/chan 4))
(defn writer []
(for i 0 10
(ev/sleep 0.1)
(print "writer giving item " i "...")
(ev/give c (string "item " i))))
(defn reader [name]
(forever
(print "reader " name " got " (ev/take c))))
(ev/call writer)
(each letter [:a :b :c :d :e :f :g]
(ev/call reader letter))