Please also note the existence of (future-call), which takes a no-arg
fn instead of a body,
HTH,
--
Laurent
On 25 nov, 17:21, David Brown wrote:
> On Tue, Nov 24, 2009 at 09:04:38PM -0800, Hong Jiang wrote:
> >Hi all,
>
> >I'm new to Clojure and playing with small programs. Today I wrote a
> >s
On Thu, Nov 26, 2009 at 2:11 AM, Christophe Grand wrote:
> On Thu, Nov 26, 2009 at 8:05 AM, Robert Campbell wrote:
>
>> If you have this:
>>
>> user> (def f (future (Thread/sleep 2) :done))
>> #'user/f
>> user> @f ; this immediate deref blocks for 20 sec, finally returning
>> :block
>> :done
On Thu, Nov 26, 2009 at 8:05 AM, Robert Campbell wrote:
> If you have this:
>
> user> (def f (future (Thread/sleep 2) :done))
> #'user/f
> user> @f ; this immediate deref blocks for 20 sec, finally returning
> :block
> :done
> user> @f ; returns immediately
> :done
>
> What is actually happ
If you have this:
user> (def f (future (Thread/sleep 2) :done))
#'user/f
user> @f ; this immediate deref blocks for 20 sec, finally returning :block
:done
user> @f ; returns immediately
:done
What is actually happening when you call the first @f? You are waiting
for the function to finish e
Thanks. Yeah, after adding a call to shutdown-agents, the process no
longer hangs.
On Nov 25, 1:15 pm, Kevin Downey wrote:
> future also uses the same threadpool as agents, so once you call
> future the threadpool spins up, and just sort of sits around for a
> while before the jvm decides to exit
future also uses the same threadpool as agents, so once you call
future the threadpool spins up, and just sort of sits around for a
while before the jvm decides to exit, which is why the program would
sit around for 50 seconds
On Wed, Nov 25, 2009 at 10:30 AM, Hong Jiang wrote:
> Thanks for your
Thanks for your replies David and Sean. Yes, I made a mistake thinking
that future takes a function and its arguments, so the function was
never called in my program.
On Nov 25, 8:21 am, David Brown wrote:
> On Tue, Nov 24, 2009 at 09:04:38PM -0800, Hong Jiang wrote:
> >Hi all,
>
> >I'm new to Cl
Hi,
On Nov 25, 6:04 am, Hong Jiang wrote:
> I'm new to Clojure and playing with small programs. Today I wrote a
> snippet to figure out how future works:
>
> (defn testf []
> (let [f (future #(do
> (Thread/sleep 5000)
> %)
> 5)
>
On Tue, Nov 24, 2009 at 09:04:38PM -0800, Hong Jiang wrote:
>Hi all,
>
>I'm new to Clojure and playing with small programs. Today I wrote a
>snippet to figure out how future works:
>
>(defn testf []
> (let [f (future #(do
> (Thread/sleep 5000)
> %)
>
I'm not quite sure what you're seeing. You might want to use the time
macro to help.
Here's what I was able to do:
user=> (time ((fn [] (let [f (future (#(do (Thread/sleep 5000) %) 5))
g 7] (+ g @f)
"Elapsed time: 4975.917889 msecs"
12
Sean
On Nov 25, 12:04 am, Hong Jiang wrote:
> Hi all,
Hi all,
I'm new to Clojure and playing with small programs. Today I wrote a
snippet to figure out how future works:
(defn testf []
(let [f (future #(do
(Thread/sleep 5000)
%)
5)
g 7]
(+ g @f)))
(println (testf))
I'm expec
11 matches
Mail list logo