JanetDocsPlaygroundI'm feeling luckyGitHub sign in

ev/chan-close



    cfunction
    src/core/ev.c on line 1113, column 1

    (ev/chan-close chan)

    Close a channel. A closed channel will cause all pending reads and 
    writes to return nil. Returns the channel.


1 exampleSign in to add an example
Loading...
(def channel (ev/chan))

(ev/spawn
 (do
   (for i 0 10
     (ev/give channel (math/random))
     (ev/sleep 0.25))
   (ev/chan-close channel)))

(defn consumer [name delay]
  (loop [item :iterate (ev/take channel)]
    (match item
      [:close _] nil
      v (print name " got " v))))

(ev/call consumer "bob" 1)
(ev/call consumer "alice" 3)
txgruppiPlayground