Thanks for finding that Moritz :)

I am not using the value from the current agent in the new agent though, so 
this dispatch delay is a little annoying.

I suppose I can use a future instead of an agent, though it doesn't have all 
the nice properties that agents do (once action a time).

Maybe I'll write a function that pulls from a BlockingQueue and run it on a 
Thread.

Anyway, thanks again.

Dan


On Jun 12, 2010, at 3:46 PM, Moritz Ulrich wrote:

> Sorry for the second mail, but here is the passage from clojure.org
> which mentions the behavior you've seen:
> 
> "5. If during the function execution any other dispatches are made
> (directly or indirectly), they will be held until after the state of
> the Agent has been changed."
> 
> 
> Maybe it's done to prevent problems when the function the
> currently-active agent sent to another agent depends on the value of
> the original agent.
> 
> On Sat, Jun 12, 2010 at 9:43 PM, Moritz Ulrich
> <ulrich.mor...@googlemail.com> wrote:
>> I'm not sure why it's doing this, but I read about this in the api
>> documentation - It's intended
>> 
>> On Sat, Jun 12, 2010 at 9:41 PM, Dan Larkin <d...@danlarkin.org> wrote:
>>> Hey all,
>>> 
>>> I've cooked up this example code to demonstrate a point:
>>> 
>>> (send-off
>>>  (agent nil)
>>>  (fn [_]
>>>   (send-off
>>>    (agent nil)
>>>    (fn [_]
>>>      (println "Hey!")))
>>>   (Thread/sleep 4000))) ; "Hey!" isn't printed for 4 seconds (when the 
>>> outer agent finishes).
>>> 
>>> Which is that actions sent to an agent from another agent won't be started 
>>> until the first agent returns from its current action.
>>> 
>>> Does anyone have insight as to the reasoning here? Is it a bug? If it's 
>>> intended behavior is there something I can do to circumvent it?
>>> 
>>> 
>>> Dan
>>> 
>>> --
>>> 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
>> 
>> 
>> 
>> --
>> Moritz Ulrich
>> Programmer, Student, Almost normal Guy
>> 
>> http://www.google.com/profiles/ulrich.moritz
>> 
> 
> 
> 
> -- 
> Moritz Ulrich
> Programmer, Student, Almost normal Guy
> 
> http://www.google.com/profiles/ulrich.moritz
> 
> -- 
> 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 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