cfunction
src/core/ev.c on line 1091, column 1
(ev/chan &opt capacity)
Create a new channel. capacity is the number of values to queue
before blocking writers, defaults to 0 if not provided. Returns a
new channel.
# create a channel without buffer, default is 0
(def channel (ev/chan))
(ev/spawn
(ev/sleep 5)
(ev/give channel "Hard work is done!"))
(print "do anything")
(for i 0 5
(print i)
(ev/sleep 0.5))
(print (ev/take channel)) # blocks here, until there is a result in the channel
(print "done")
(def chan (ev/chan))
(def f (ev/go (coro (yield "world")) nil chan))
(def [sig fib] (ev/take chan))
(pp sig) # => prints :yield
(pp (fiber/last-value fib)) # => prints world