mirror of https://github.com/status-im/timbre.git
[#141] Housekeeping
This commit is contained in:
parent
d59d902611
commit
47cf2121f6
|
@ -565,18 +565,18 @@
|
||||||
(def get-hostname
|
(def get-hostname
|
||||||
(enc/memoize* (enc/ms :mins 1)
|
(enc/memoize* (enc/ms :mins 1)
|
||||||
(fn []
|
(fn []
|
||||||
;; Android doesn't like this on the main thread
|
;; Android doesn't like this on the main thread. Would use a `future` but
|
||||||
;; `future` starts the agent threadpool so we use
|
;; that starts the Clojure agent threadpool which can slow application
|
||||||
;; java.util.concurrent.
|
;; shutdown w/o a `(shutdown-agents)` call
|
||||||
(let [executor (java.util.concurrent.Executors/newSingleThreadExecutor)
|
(let [executor (java.util.concurrent.Executors/newSingleThreadExecutor)
|
||||||
f_ (.submit executor
|
f_ (.submit executor ^java.util.concurrent.Callable
|
||||||
^java.util.concurrent.Callable
|
|
||||||
(fn []
|
(fn []
|
||||||
(try (.. java.net.InetAddress getLocalHost getHostName)
|
|
||||||
(catch java.net.UnknownHostException _ "UnknownHost"))))]
|
|
||||||
(try
|
(try
|
||||||
(deref f_ 5000 "UnknownHost")
|
(.. java.net.InetAddress getLocalHost getHostName)
|
||||||
(finally (.shutdown executor)))))))
|
(catch java.net.UnknownHostException _ "UnknownHost")
|
||||||
|
(finally (.shutdown executor)))))]
|
||||||
|
|
||||||
|
(deref f_ 5000 "UnknownHost")))))
|
||||||
|
|
||||||
(comment (get-hostname))
|
(comment (get-hostname))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue