From 19d80b25fdaca8ee1f2d7314faba728865d2f6c0 Mon Sep 17 00:00:00 2001 From: Trevor Hartman Date: Tue, 22 Dec 2015 18:05:15 -0700 Subject: [PATCH] Use future instead of Thread. to preserve bindings --- src/irclj/core.clj | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/irclj/core.clj b/src/irclj/core.clj index 9a1f68a..cbe6e62 100644 --- a/src/irclj/core.clj +++ b/src/irclj/core.clj @@ -139,21 +139,19 @@ :init-mode mode :network host :ready? (promise)})] - (.start - (Thread. - (fn [] - (try - (connection/set-timeout irc timeout) - (connection/register-connection irc) - (loop [lines (connection/safe-line-seq in)] - (if-let [line (first lines)] - (do (process irc line) - (recur (rest lines))) - (events/fire irc :on-shutdown))) - (catch Exception e - (deliver (:ready? @irc) false) ;; unblock the promise - (events/fire irc :on-exception e) - (throw e)))))) + (future + (try + (connection/set-timeout irc timeout) + (connection/register-connection irc) + (loop [lines (connection/safe-line-seq in)] + (if-let [line (first lines)] + (do (process irc line) + (recur (rest lines))) + (events/fire irc :on-shutdown))) + (catch Exception e + (deliver (:ready? @irc) false) ;; unblock the promise + (events/fire irc :on-exception e) + (throw e)))) irc))