> question is about clojure.lang.Agent. In the doRun method, I'm missing > what prevents a race condition in the updating of the agent's state > variable.
Unless I am misunderstanding the context in which the code runs, I believe it is correct because doRun() is guaranteed never to run concurrently (because agents mutate state by function application in a serialized fashion). If I understand it correctly (and someone correct me if I'm wrong), enqueue() is the initial entry point to execution. It will trigger execution if the agent was not already running and had nothing queued. doRun() itself keeps itself running until it manages to empty the queue, at which point a future enqueue() will once again re-start execution. -- / Peter Schuller -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en