Skip to content

Instantly share code, notes, and snippets.

@hsgrott
Last active November 17, 2015 18:36
Show Gist options
  • Save hsgrott/258e419db4a6ea31f76e to your computer and use it in GitHub Desktop.
Save hsgrott/258e419db4a6ea31f76e to your computer and use it in GitHub Desktop.
Pulsar test
(ns test-pulsar.core
(:require
[co.paralleluniverse.pulsar
[core :refer :all]
[actors :refer :all]])
(:refer-clojure :exclude [promise await])
(:gen-class))
(defn ping [n pong]
(if (== n 0)
(do
(! pong :finished)
(println "ping finished"))
(do
(! pong [:ping @self])
(receive
:pong (println "Ping received pong"))
(recur (dec n) pong))))
(defn pong
[]
(receive
:finished (println "Pong finished")
[:ping ping] (do
(println "Pong received ping")
(! ping :pong)
(recur))))
(defn main []
(let [a1 (spawn pong)
b1 (spawn ping 3 a1)]
(join a1)
(join b1)
:ok))
(defproject test-pulsar "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.7.0"]
[co.paralleluniverse/pulsar "0.7.3"]]
:java-agents [[co.paralleluniverse/quasar-core "0.7.3" :classifier "jdk8"]]
:main ^:skip-aot test-pulsar.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment