I can't speak for whether this is a truly idiomatic way of doing this, but this is a macro i've been using for this case.
(defmacro plet [bindings & body] "Just like let, but evaluates bindings in parallel" (let [bindings (partition-all 2 bindings) destructs (map first bindings) expressions (map second bindings) vars (repeatedly (count bindings) gensym)] `(let [~@(mapcat (fn [var expr] `[~var (future ~expr)]) vars expressions) ~@(mapcat (fn [destr var] `[~destr (deref ~var)]) destructs vars)] ~@body))) This gives me a similar construct to let, but with each binding evaluated in parallel using a future. For small sets i think this is less overhead than pmap - note that unlike the traditional let, this will not handle multiple bindings for the same variable properly. Usage would then be (plet [a (http/get "url1") b (http/get "url2")] (vec a b)) Or similar Cheers Glen On Tuesday, 31 December 2013 08:46:53 UTC, chinmoy debnath wrote: > > I am a newbie in clojure. I need to send multiple http requests in > parallel and need to have a call back when response for each request come > back. What will be the idiomatic way of doing it in clojure? > Thanks in advacne > > -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.