On Apr 16, 11:25 am, Drew Raines <aarai...@gmail.com> wrote:
> I have a command line utility that calls (exit 0) at the end of
> (-main).  It looks like this:
>
>   (defn exit [status]
>     (shutdown-agents)
>     (flush)
>     (System/exit status))
>
> Yet, despite this, the JVM never exits.

The documentation for "shutdown-agents" says "Initiates a shutdown of
the thread pools that back the agent system. Running actions will
complete, but no new actions will be accepted".

I think you are responsible for ending the currently running agents.
The usual method is to set up some field which the agents monitor
looking for some value indicating the application is ending.

You have a command-line utility, so the following doesn't apply to
your case. I have a gui application with multiple windows for each
"document". When the document window closes, I need to stop the
associated agents for that window. Rather than set up some field as I
suggested above, I do the following.

===========================
(defn bossAgentAction [_ achiGameHandle #^JFrame achiFrame]
  (when (.isDisplayable achiFrame)
        ....
        (send-off *agent* #'bossAgentAction achiGameHandle achiFrame)))
  nil)
===========================

That is, I use the JFrame itself to indicate when the agent thread
should terminate.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to