It's not send and send-off that are blocking, it is your (println "Final"... send expects a function, so it is waiting for "(println..." to return some function to apply to the agent.
On Tue, Aug 24, 2010 at 9:16 AM, Timothy Washington <twash...@gmail.com>wrote: > Ok, I have a dumb question here. Using Clojure's concurrency semantics, I'm > trying to see how to spawn a thread that runs and blocks on input from the > standard-in. Vars, atoms, agents and refs all seem to deal with coordinated > / uncoordinated access to blocks of data. > > I need i) to call a function (in a thread) that runs and blocks on standard > input. Then ii) run a thread that spits data to the standard in. I tried > create an agent with nil data, then sending an update function to the agent; > but no dice. > > *(let [agt (agent nil)] * > * (send agt ** **;; both send and send-off still block execution - > (println "foobar") never gets called * > * (println "FINAL > " * > * (with-out-str (some-function-that-blocks-on-read )))* > * nil * > * ) * > *)* > * * > *(println "foobar") * > > > I want to avoid using Java threads if at all possible. > > Hmmm > Tim > > -- > 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<clojure%2bunsubscr...@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