Re: scheduling with core.async?

2015-09-23 Thread Thomas Heller
To be honest I see no point in using core.async or any other library for 
that matter. Java already solves this problem very well.

(ns ...
  (:import [java.util.concurrent TimeUnit Executors]))

(def scheduler
  (doto (Executors/newSingleThreadScheduledExecutor)
(.scheduleAtFixedRate
 the-function-that-gets-called-every-hour
 0 ;; initial delay till execution starts
 1 ;; delay between each runs
 TimeUnit/HOURS ;; the unit of the above two values
 )))

When and where you set this up is dependent on your app and you must 
remember to (.shutdown scheduler) at some point, but beyond that it is 
pretty simple.

HTH,
/thomas

On Wednesday, September 23, 2015 at 1:00:32 PM UTC+2, bahadir cambel wrote:
>
>
> Hi Leon, 
>
> you may check http://www.clojure-toolbox.com/ and see the schedule 
> section. Here are the suggestions; 
>
> https://github.com/jarohen/chime (has core.async examples)
> https://github.com/overtone/at-at
> https://github.com/zcaudate/cronj
>
> Also, if you're using HTTP-Kit http://www.http-kit.org/timer.html
>
> Cheers,
> Bahadir
> twitter.com/bahadircambel
>
>
>
>
>
>
> On Tuesday, September 22, 2015 at 4:35:37 PM UTC+2, Leon Grapenthin wrote:
>>
>> Is it recommended to use core.asyncs timeout channel to wait on hour or 
>> even longer for light scheduling tasks?
>>
>> High precision is a nongoal.
>>
>> Kind regards,
>>  Leon.
>>
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: scheduling with core.async?

2015-09-23 Thread bahadir cambel

Hi Leon, 

you may check http://www.clojure-toolbox.com/ and see the schedule section. 
Here are the suggestions; 

https://github.com/jarohen/chime (has core.async examples)
https://github.com/overtone/at-at
https://github.com/zcaudate/cronj

Also, if you're using HTTP-Kit http://www.http-kit.org/timer.html

Cheers,
Bahadir
twitter.com/bahadircambel






On Tuesday, September 22, 2015 at 4:35:37 PM UTC+2, Leon Grapenthin wrote:
>
> Is it recommended to use core.asyncs timeout channel to wait on hour or 
> even longer for light scheduling tasks?
>
> High precision is a nongoal.
>
> Kind regards,
>  Leon.
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: scheduling with core.async?

2015-09-23 Thread Gerrit Jansen van Vuuren
 from my own experience with core async I;d say yes

I've made two macros
 https://github.com/gerritjvv/fun-utils/blob/master/src/fun_utils/core.clj#L208 
and
https://github.com/gerritjvv/fun-utils/blob/master/src/fun_utils/core.clj#L220
 that does exactly what you're referring to.

Remember if you're going to schedule a task that uses IO or takes some time 
then you need to use a thread and not a general (go ) block, 
this is what fixdelay-thread does, otherwise you end up blocking the 
general core.async thread pool.


On Tuesday, 22 September 2015 16:35:37 UTC+2, Leon Grapenthin wrote:
>
> Is it recommended to use core.asyncs timeout channel to wait on hour or 
> even longer for light scheduling tasks?
>
> High precision is a nongoal.
>
> Kind regards,
>  Leon.
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.