Skip to content

Instantly share code, notes, and snippets.

@Jared314
Created July 21, 2013 04:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Jared314/6047489 to your computer and use it in GitHub Desktop.
Clojure core.async example 2
(ns async2
(:require [clojure.core.async :as async]
[clojure.core.async.lab :as lab]))
(defn make-fb-group [& members]
(apply lab/broadcast members))
(defn alice [c]
(async/>!! c "Dave Davenson's House @ 10pm"))
(defn bob []
(let [c (async/chan 1)]
(async/go (println "Bob received: " (async/<! c)))
c))
(defn carol []
(let [c (async/chan 1)]
(async/go (println "Carol received: " (async/<! c)))
c))
(let [fb-group (make-fb-group (bob) (carol))]
; Alice sends the message to the group
(alice fb-group))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment