puniverse / pulsar

Fibers, Channels and Actors for Clojure
http://docs.paralleluniverse.co/pulsar/
Other
911 stars 53 forks source link

watch! fails when called from within a receive with an :else clause #59

Closed lkonstantinov closed 8 years ago

lkonstantinov commented 8 years ago

Running with Clojure 1.8.0 and

[co.paralleluniverse/quasar-core "0.7.5"] [co.paralleluniverse/pulsar "0.7.5"]

I have two actors setup like this:

(defsfn act1 []
        (receive [m]
                 [peer message] (do
                                  (println "got message " + message + " from peer " peer)
                                  (watch! peer))
                 [:exit w peer reason] (println "peer left" peer)
                 :else (println "got unhandled message " m))
        (recur))

(defsfn act2 [] (receive [m] :xx (println "bye") :else (do (println "got " m) (recur))))

Running this in nREPL:

(def a1 (spawn act1))
(def a2 (spawn act2))

(! a1 [a2 "hello])
(! a2 :xx)

The [:exit] clause never gets hit in act1. If I remove the :else clause, everything works as expected, i.e. the "peer left" message is being printed.