Use let scope to bing the agent

This commit is contained in:
Ignacy Moryc 2012-09-23 15:38:31 +02:00
parent 00385eee11
commit c8f711e209

View file

@ -1,8 +1,6 @@
(def agent-example
"Agents provide shared access to mutable state."
(agent 10))
(meditations (meditations
(let [agent-example (agent 10)]
"Creating an Agent is as simple as assigning it a value" "Creating an Agent is as simple as assigning it a value"
(= __ (instance? clojure.lang.Agent agent-example)) (= __ (instance? clojure.lang.Agent agent-example))
@ -28,4 +26,7 @@
(try (try
(send agent-example + 1) (send agent-example + 1)
(catch IllegalStateException e)) (catch IllegalStateException e))
@agent-example))) @agent-example))
"It's a good idea to clean up any not finished agents after you are done"
(shutdown-agents)))