Paul,
Thanks... but I want the opposite of delay.
Basically, I do not want to consume a thread waiting for a Future to be
satisfied. I want to continue a computation on a different thread once the
Future/Promise is satisfied. Why?
Think of a web app that's serving either a long poll or a web soc
Oh! I see, you want promises with callbacks (which you want to be futures).
Once a promise is delivered, you want to kick off a future (in Clojure,
futures consume a thread from the thread pool to do their work).
It's been discussed before:
https://groups.google.com/forum/?fromgroups=#!topic/cl
You might find this work in progress interesting then:
http://github.com/clojure/core.async
On Thu, May 30, 2013 at 3:46 PM, David Pollak wrote:
> Paul,
>
> Thanks... but I want the opposite of delay.
>
> Basically, I do not want to consume a thread waiting for a Future to be
> satisfied. I wan
I'm not entirely sure what you're trying to accomplish in a larger context,
but perhaps you're looking for something like this?
(delay (deref (future (and (Thread/sleep 2000) (+ 1 2)
... or maybe you want just `delay`
Cheers,
Paul
On Thursday, May 30, 2013 6:09:02 AM UTC-7, David Pollak w
Okay... I wrote my own:
https://github.com/projectplugh/plugh/blob/master/src/plugh/util/misc.clj#L51
One can register for on-done and on-fail. I'll work on adding fail-fast and
also map (so one can transform the future and execute code when the
transformed future has been realized/delivered/fini
by the second future, I mean an instance of
http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html ,
which just has to conform to the interface, and doesn't actually have to
execute on a different thread. Clojure's 'future' function returns an
instance of one of these that uses
Maybe an easy solution: wrap the first future in another future that
blocking-derefs, then performs your extra computation? Do an extra
'realized?' check for the optimization you mention. That would still
consume threads in the case that it's not realized, but I think it gets you
what you want.
According to this article, Clojure does not yet have this facility:
http://java.dzone.com/articles/promises-and-futures-clojure
This is something that is being worked on and discussed, though:
http://dev.clojure.org/display/design/Promises
https://groups.google.com/forum/#!topic/clojure-dev/7BKQi9
Howdy,
I'm looking at using Future/Promise to be thread-friendly in some code.
Background... Lift has Futures (or LAFuture... yeah... go ahead make fun of
the name... pronounce it with a French accent)... with Lift futures, one
can do:
future.foreach(v => /* do something with the value */)
If t