On Wed, Jul 7, 2010 at 3:10 PM, James Reeves <jree...@weavejester.com> wrote: > On 7 July 2010 19:04, David Nolen <dnolen.li...@gmail.com> wrote: >> So something like this: >> (defn hello-world [request] >> (future >> (Thread/sleep 1) >> (respond! request >> {:status 200 >> :headers {"Content-Type" "text/html"} >> :body "Hello world!"}))) >> Is non-blocking and perfectly fine? > > Actually that rather defeats the point of a non-blocking server. > You're still using up a thread, and hence haven't really gained > anything over: > > (defn hello-world [request] > (Thread/sleep 1) > {:status 200 > :headers {"Content-Type" "text/html"} > :body "Hello world!"}) > > The main advantage of a non-blocking server is that you're don't use > up a thread waiting for an event (such as the user sending data, or > some other external trigger).
Actually, a huge benefit of a non-blocking http server is that it won't create a thread per request. But, don't seen any problem the use code spawing threads to handle work for one particular request. In clojure, I think it'll be hard to go NIO all the way (like in node.js). -- 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