1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.channel.epoll;
17
18 import io.netty.channel.DefaultSelectStrategyFactory;
19 import io.netty.channel.EventLoopGroup;
20 import io.netty.channel.MultithreadEventLoopGroup;
21 import io.netty.channel.SelectStrategyFactory;
22 import io.netty.util.concurrent.EventExecutor;
23 import io.netty.util.concurrent.RejectedExecutionHandler;
24 import io.netty.util.concurrent.RejectedExecutionHandlers;
25
26 import java.util.concurrent.ThreadFactory;
27
28
29
30
31
32 public final class EpollEventLoopGroup extends MultithreadEventLoopGroup {
33 {
34
35 Epoll.ensureAvailability();
36 }
37
38
39
40
41 public EpollEventLoopGroup() {
42 this(0);
43 }
44
45
46
47
48 public EpollEventLoopGroup(int nThreads) {
49 this(nThreads, (ThreadFactory) null);
50 }
51
52
53
54
55 @SuppressWarnings("deprecation")
56 public EpollEventLoopGroup(int nThreads, SelectStrategyFactory selectStrategyFactory) {
57 this(nThreads, null, selectStrategyFactory);
58 }
59
60
61
62
63 @SuppressWarnings("deprecation")
64 public EpollEventLoopGroup(int nThreads, ThreadFactory threadFactory) {
65 this(nThreads, threadFactory, 0);
66 }
67
68
69
70
71 @SuppressWarnings("deprecation")
72 public EpollEventLoopGroup(int nThreads, ThreadFactory threadFactory, SelectStrategyFactory selectStrategyFactory) {
73 this(nThreads, threadFactory, 0, selectStrategyFactory);
74 }
75
76
77
78
79
80
81
82 @Deprecated
83 public EpollEventLoopGroup(int nThreads, ThreadFactory threadFactory, int maxEventsAtOnce) {
84 this(nThreads, threadFactory, maxEventsAtOnce, DefaultSelectStrategyFactory.INSTANCE);
85 }
86
87
88
89
90
91
92
93
94 @Deprecated
95 public EpollEventLoopGroup(int nThreads, ThreadFactory threadFactory, int maxEventsAtOnce,
96 SelectStrategyFactory selectStrategyFactory) {
97 super(nThreads, threadFactory, maxEventsAtOnce, selectStrategyFactory, RejectedExecutionHandlers.reject());
98 }
99
100 public EpollEventLoopGroup(int nThreads, ThreadFactory threadFactory, int maxEventsAtOnce,
101 SelectStrategyFactory selectStrategyFactory,
102 RejectedExecutionHandler rejectedExecutionHandler) {
103 super(nThreads, threadFactory, maxEventsAtOnce, selectStrategyFactory, rejectedExecutionHandler);
104 }
105
106
107
108
109
110 public void setIoRatio(int ioRatio) {
111 for (EventExecutor e: children()) {
112 ((EpollEventLoop) e).setIoRatio(ioRatio);
113 }
114 }
115
116 @Override
117 protected EventExecutor newChild(ThreadFactory threadFactory, Object... args) throws Exception {
118 return new EpollEventLoop(this, threadFactory, (Integer) args[0],
119 ((SelectStrategyFactory) args[1]).newSelectStrategy(), (RejectedExecutionHandler) args[2]);
120 }
121 }