It might be nice to have a built-in mechanism to get with a timeout.
Maybe (await-for ...) could be modified to work on both agents and
promises?

Note though, that getting a promise with a timeout doesn't require
explicitly closing over the promise.  The anonymous function that is
created in the osc-recv function I pasted above is necessary because
it gets run asynchronously by a server socket thread.  Getting with a
timeout versus without one is the difference of:

; blocking deref
@p

; deref with 100ms timeout
(.get (future @p) 100 TimeUnit/MILLISECONDS)

-Jeff

On Jan 23, 4:17 pm, "Steven E. Harris" <s...@panix.com> wrote:
> Jeff Rose <ros...@gmail.com> writes:
> > The future is used because they have a timeout feature when using the
> > .get method.
>
> Should there be a corresponding timeout-based `deref' function¹
> ("deref-within"?) for promises? Having to close a function over your
> "@p" form and spawn a job on a separate thread seems like way too much
> work just to get a timeout-based wait on the promise's delivery
> arriving.
>
> Footnotes:
> ¹http://richhickey.github.com/clojure/clojure.core-api.html#clojure.co...
>
> --
> Steven E. Harris

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

Reply via email to