Hi Rich, hi all, A question: is it possible to kill or interrupt an agent during a long- running action, e.g.,
(def the-agent (agent nil)) (send-off the-agent really-long-action) ;; Oops, I changed my mind. (interrupt the-agent) ;; The thread running really-long-action stops, aborting any ;; transactions, and the-agent is free to receive another action. The java.lang.Thread docs make it clear that killing off threads arbitrarily is a bad idea, because any objects in use by those threads could be left in an inconsistent state. But I assume Clojure's STM could take care of that problem. One option would be to use a second agent as a flag. My really-long- action function could periodically check the value of that agent, and terminate if it's been set to true. But would it be possible to provide a generic interrupt mechanism that doesn't require modifying the action function? My use-case is a REPL-like utility that can run each expression the user types in a separate thread, and can kill off threads that are misbehaving or not terminating. -Stuart Sierra --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---