On 7 July 2010 19:04, David Nolen <[email protected]> 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).
- James
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en