Imagine: flat world n*n cells. There are moving objects. They can collide, and according to process one of them should be destroyed.
I am using the ideas from ant colony of Rich Hickey to represent objects as agents. So after collision one of agent must stop his work after receiving message from other agent.
There is a code snippet to illustrate my problem: second agent stops unexpectedly.
;agents
(def f_guy (agent nil))
(def s_guy (agent nil))
;functions for agents
(defn f_do [x]
(do
(Thread/sleep 20)
(println "f")
(send-off *agent* f_do)))
(defn s_do [x]
(do
(Thread/sleep 40)
(println "s")
(send-off f_guy nil)
(send-off *agent* s_do)))
;the process
(defn start []
(do
(send-off f_guy f_do)
(send-off s_guy s_do)))
;go
(start)
Thank you!
You sent
f_guya request to callnilas a function. He did, and that got him into a broken state by throwing an exception. Then, you ask him to callnilagain. But he can’t even agree to do that, because he is broken and waiting for someone to fix him. Sos_guyis hanging around waiting forf_guyto acknowledge (not necessarily perform, yet) the request, andf_guyhas clocked out for the day.