hi,
I could use some help figuring out why this is working the way it is. It
seems like a future function call is rebinding *out* so I don't see some
printlns at the repl.
I have a couple of functions for a server like this,
(defn run [handler]
(let
[server (create-server)
selector (:selector server)
start (fn [] (future (handler server)))
shutdown (fn []
(println "Shutting down...")
(doseq [k (.keys selector)]
(.close (.channel k)))
(.close selector)
(println "...done.")
)]
{:server server :start start :shutdown shutdown}))
(defn app [server]
(let
[acceptor (:acceptor server)
selector (:selector server)]
(println "Starting Ex v Arcis on" (.getLocalAddress acceptor))
(while (.isOpen selector)
(select! selector)
(echo-all (filter #(and (.isValid %) (.attachment %)) (.keys
selector)))
(Thread/sleep 3000))
(println "after")))
And a repl session looks like this,
exvarcis.core> (def my-server (run #'app))
#'exvarcis.core/my-server
exvarcis.core> ((:start my-server))
#<core$future_call$reify__6110@1f9c9e3: :pending>
Starting Ex v Arcis on #<InetSocketAddress /127.0.0.1:1325>
exvarcis.core> ((:shutdown my-server))
Shutting down...
...done.
nil
exvarcis.core>
So I never see the "after" called after the while loop.
If I comment out the while loop, I do see it.
Anyone have a clue why this is working like it is?
thanks, George
--
--
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
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.