Permalink
Browse files

- all connections now share one single HashWheelTimer

  • Loading branch information...
1 parent 3490a80 commit d741e4704f650eeb4fde2fd3e538b4003d168dc4 @niclasmeier niclasmeier committed Oct 22, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/herolabs/apns/push.clj
View
7 src/herolabs/apns/push.clj
@@ -33,6 +33,10 @@
t (if (not= Thread/NORM_PRIORITY (.getPriority t)) (.setPriority t Thread/NORM_PRIORITY) t)]
t)))))))))
+(def ^:private timer* (ref nil))
+
+(defn timer- [] (or @timer* (dosync (alter timer* (fn [_] (HashedWheelTimer.))))))
+
(defmacro future-listener [params & body]
(cond
(not (vector? params)) (throw (IllegalArgumentException. "Parameter have to be a vector."))
@@ -102,9 +106,8 @@
boss-executor worker-executor) (ClientBootstrap.))
ssl-handler-factory (create-ssl-handler-factory engine-factory)
client-handle (atom nil)
- timer (HashedWheelTimer.)
pipeline-factory (create-pipeline-factory ssl-handler-factory (handler bootstrap ssl-handler-factory client-handle
- exception-handler) timer time-out)
+ exception-handler) (timer) time-out)
bootstrap (doto bootstrap
(.setOption "connectTimeoutMillis" 5000)
(.setPipelineFactory pipeline-factory)

0 comments on commit d741e47

Please sign in to comment.