For instance you can use schejulure [1] or at-at [2] and make sure the
scheduled function calls put an item (event) on the channel and then made
the scheduler do the pausing work.

All the "listeners" attached to the channel will receive the events at the
time the scheduler "releases" them, and you don't have to manage anything
regarding timing/pausing.

/Linus


[1] https://github.com/AdamClements/schejulure
[2] https://github.com/overtone/at-at


2014-09-11 13:52 GMT+02:00 Jeremy Vuillermet <jeremy.vuiller...@gmail.com>:

> Hello,
>
> here is my use case
>
> (defn replay [history] (go (doseq [millis history]
>                                           (<! (timeout millis))
>                                           (prn millis))))
>
> history is a vector of duration: [1000 2000 4000]
>
> Now I would like to pause this doseq. One way is to use an atom pause?,
> check for the pause and block until a new value in a "resume" chan.
>
> But there may be an other way with channels only and avoid global/shared
> pause atom.
> I was naively thinking of a pause channel and at each loop I check if
> there is a value but I'm not sure it's better and I couldn't manage to do
> it anyway.
>
> --
> 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.
>

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

Reply via email to