Maybe I'm confused, but can't you just do a regular java thread for
this?
(defn periodicly [fun time]
"starts a thread that calls function every time ms"
(let [thread (new Thread (fn [] (loop [] (fun) (Thread/sleep time)
(recur))))]
(.start thread)
thread))
(periodicly #(println "foo foo foo") 3000)
I'm not really sure about the error handling thing, but I guess you
could wrap the function in a try-catch where it reinitialized itself.
(although I guess that could get dangerous if you start throwing a lot
of errors).
On Oct 29, 11:05 pm, Stefan Arentz <[email protected]> wrote:
> What is a good and simple way to run periodic tasks in Clojure? I need
> to run a simple function every couple of minutes. And make sure that
> if it throws an exception that it won't kill the periodic task.
>
> I come from a Spring world where XML, Timers, Jobs and Quartz rule the
> world, so am hoping for something small and elegant for Closure :-)
>
> S.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---