|
4 | 4 | [byte-streams :as bs]
|
5 | 5 | [clojure.tools.logging :as log]
|
6 | 6 | [manifold.deferred :as d]
|
| 7 | + [manifold.executor :as e] |
7 | 8 | [manifold.stream :as s]
|
8 | 9 | [manifold.stream.core :as manifold]
|
9 | 10 | [primitive-math :as p]
|
|
51 | 52 | ResourceLeakDetector$Level]
|
52 | 53 | [java.net URI SocketAddress InetSocketAddress]
|
53 | 54 | [io.netty.util.concurrent
|
54 |
| - GenericFutureListener Future DefaultThreadFactory] |
| 55 | + GenericFutureListener Future] |
55 | 56 | [java.io InputStream File]
|
56 | 57 | [java.nio ByteBuffer]
|
57 | 58 | [io.netty.util.internal SystemPropertyUtil]
|
58 | 59 | [java.util.concurrent
|
59 |
| - ConcurrentHashMap CancellationException ScheduledFuture TimeUnit] |
| 60 | + ConcurrentHashMap |
| 61 | + CancellationException |
| 62 | + ScheduledFuture |
| 63 | + TimeUnit |
| 64 | + ThreadFactory] |
60 | 65 | [java.util.concurrent.atomic
|
61 | 66 | AtomicLong]
|
62 | 67 | [io.netty.util.internal.logging
|
|
721 | 726 | (let [cpu-count (->> (Runtime/getRuntime) (.availableProcessors))]
|
722 | 727 | (max 1 (SystemPropertyUtil/getInt "io.netty.eventLoopThreads" (* cpu-count 2)))))
|
723 | 728 |
|
| 729 | +(defn ^ThreadFactory enumerating-thread-factory [prefix daemon?] |
| 730 | + (let [num-threads (atom 0)] |
| 731 | + (e/thread-factory |
| 732 | + #(str prefix "-" (swap! num-threads inc)) |
| 733 | + (deliver (promise) nil) |
| 734 | + nil |
| 735 | + daemon?))) |
| 736 | + |
724 | 737 | (def ^String client-event-thread-pool-name "aleph-netty-client-event-pool")
|
725 | 738 |
|
726 | 739 | (def epoll-client-group
|
727 | 740 | (delay
|
728 | 741 | (let [thread-count (get-default-event-loop-threads)
|
729 |
| - thread-factory (DefaultThreadFactory. client-event-thread-pool-name true)] |
| 742 | + thread-factory (enumerating-thread-factory client-event-thread-pool-name true)] |
730 | 743 | (EpollEventLoopGroup. (long thread-count) thread-factory))))
|
731 | 744 |
|
732 | 745 | (def nio-client-group
|
733 | 746 | (delay
|
734 | 747 | (let [thread-count (get-default-event-loop-threads)
|
735 |
| - thread-factory (DefaultThreadFactory. client-event-thread-pool-name true)] |
| 748 | + thread-factory (enumerating-thread-factory client-event-thread-pool-name true)] |
736 | 749 | (NioEventLoopGroup. (long thread-count) thread-factory))))
|
737 | 750 |
|
738 | 751 | (defn convert-address-types [address-types]
|
|
913 | 926 | epoll?]
|
914 | 927 | (let [num-cores (.availableProcessors (Runtime/getRuntime))
|
915 | 928 | num-threads (* 2 num-cores)
|
916 |
| - thread-factory (DefaultThreadFactory. "aleph-netty-server-event-pool" false) |
| 929 | + thread-factory (enumerating-thread-factory "aleph-netty-server-event-pool" false) |
917 | 930 | closed? (atom false)
|
918 | 931 |
|
919 | 932 | ^EventLoopGroup group
|
|
0 commit comments