core: don't run getHostName on the main thread (AdamClements)

This commit is contained in:
Peter Taoussanis 2013-11-06 15:13:14 +07:00
parent 1157a0e97c
commit b0fef3d5ce
1 changed files with 9 additions and 4 deletions

View File

@ -211,10 +211,15 @@
(comment ((make-timestamp-fn "yyyy-MMM-dd" nil) (Date.)))
(def get-hostname
(utils/memoize-ttl
60000 (fn [] (try (.. java.net.InetAddress getLocalHost getHostName)
(catch java.net.UnknownHostException _
"UnknownHost")))))
(utils/memoize-ttl 60000
(fn []
(let [p (promise)]
(future ; Android doesn't like this on the main thread
(deliver p
(try (.. java.net.InetAddress getLocalHost getHostName)
(catch java.net.UnknownHostException _
"UnknownHost"))))
@p))))
(defn- wrap-appender-juxt
"Wraps compile-time appender juxt with additional runtime capabilities