I recently wrote two utility functions for core.async, and I'm wondering if 
there could be some improvemets, or if I'm reinventing the wheel and 
there's something else out there that would accomplish the same thing.

Source code is available here: 
https://github.com/JvJ/specs/blob/master/src/specs/core.cljc#L469

Here are the functions:

   - timeout-at: Like timeout, but instead of specifying a wait period, you 
   specify a point in time when you want the channel to close. (Uses clj-time 
   DateTime objects).
   - beacon: Send out a signal on a channel at regular intervals of m 
   milliseconds from the present time.  Instead of waiting m milliseconds 
   every time through the loop,
   future points in time are calculated at exact intervals of m from when 
   the beacon is started.  It uses timeout-at to send the signal as closely as 
   possible to the
   requested time points.  The default output values is true.
   
   If something happens that makes one of the time points get skipped, a 
   different value is output.  The default value to indicate a skipped time 
   point is false.
   
   Beacon can also act like core/iterate if you want.  You can pass a 
   function to update both the successful output values and the skipped-time 
   output values, and
   the return value of the last output is used as the input to the function 
   to create the next output.


So, are these functions useful, or am I missing some totally obvious other 
way to do it.

By the way, the motivation here is to signal an async game update loop at a 
constant framerate, while at the same time keeping track of skipped frames.

Thanks.

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