1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-25 09:47:17 +00:00
janet/examples/channel.janet

16 lines
311 B
Plaintext
Raw Normal View History

(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))