1
16 package io.netty.channel.epoll;
17
18 import io.netty.channel.DefaultSelectStrategyFactory;
19 import io.netty.channel.EventLoop;
20 import io.netty.channel.EventLoopGroup;
21 import io.netty.channel.EventLoopTaskQueueFactory;
22 import io.netty.channel.MultithreadEventLoopGroup;
23 import io.netty.channel.SelectStrategyFactory;
24 import io.netty.util.concurrent.EventExecutorChooserFactory;
25 import io.netty.util.concurrent.RejectedExecutionHandler;
26 import io.netty.util.concurrent.RejectedExecutionHandlers;
27
28 import java.util.concurrent.Executor;
29 import java.util.concurrent.ThreadFactory;
30
31
35 public final class EpollEventLoopGroup extends MultithreadEventLoopGroup {
36 {
37
38 Epoll.ensureAvailability();
39 }
40
41
44 public EpollEventLoopGroup() {
45 this(0);
46 }
47
48
51 public EpollEventLoopGroup(int nThreads) {
52 this(nThreads, (ThreadFactory) null);
53 }
54
55
58 @SuppressWarnings("deprecation")
59 public EpollEventLoopGroup(ThreadFactory threadFactory) {
60 this(0, threadFactory, 0);
61 }
62
63
66 @SuppressWarnings("deprecation")
67 public EpollEventLoopGroup(int nThreads, SelectStrategyFactory selectStrategyFactory) {
68 this(nThreads, (ThreadFactory) null, selectStrategyFactory);
69 }
70
71
74 @SuppressWarnings("deprecation")
75 public EpollEventLoopGroup(int nThreads, ThreadFactory threadFactory) {
76 this(nThreads, threadFactory, 0);
77 }
78
79 public EpollEventLoopGroup(int nThreads, Executor executor) {
80 this(nThreads, executor, DefaultSelectStrategyFactory.INSTANCE);
81 }
82
83
86 @SuppressWarnings("deprecation")
87 public EpollEventLoopGroup(int nThreads, ThreadFactory threadFactory, SelectStrategyFactory selectStrategyFactory) {
88 this(nThreads, threadFactory, 0, selectStrategyFactory);
89 }
90
91
97 @Deprecated
98 public EpollEventLoopGroup(int nThreads, ThreadFactory threadFactory, int maxEventsAtOnce) {
99 this(nThreads, threadFactory, maxEventsAtOnce, DefaultSelectStrategyFactory.INSTANCE);
100 }
101
102
109 @Deprecated
110 public EpollEventLoopGroup(int nThreads, ThreadFactory threadFactory, int maxEventsAtOnce,
111 SelectStrategyFactory selectStrategyFactory) {
112 super(nThreads, threadFactory, maxEventsAtOnce, selectStrategyFactory, RejectedExecutionHandlers.reject());
113 }
114
115 public EpollEventLoopGroup(int nThreads, Executor executor, SelectStrategyFactory selectStrategyFactory) {
116 super(nThreads, executor, 0, selectStrategyFactory, RejectedExecutionHandlers.reject());
117 }
118
119 public EpollEventLoopGroup(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory,
120 SelectStrategyFactory selectStrategyFactory) {
121 super(nThreads, executor, chooserFactory, 0, selectStrategyFactory, RejectedExecutionHandlers.reject());
122 }
123
124 public EpollEventLoopGroup(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory,
125 SelectStrategyFactory selectStrategyFactory,
126 RejectedExecutionHandler rejectedExecutionHandler) {
127 super(nThreads, executor, chooserFactory, 0, selectStrategyFactory, rejectedExecutionHandler);
128 }
129
130 public EpollEventLoopGroup(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory,
131 SelectStrategyFactory selectStrategyFactory,
132 RejectedExecutionHandler rejectedExecutionHandler,
133 EventLoopTaskQueueFactory queueFactory) {
134 super(nThreads, executor, chooserFactory, 0, selectStrategyFactory, rejectedExecutionHandler, queueFactory);
135 }
136
137
140 @Deprecated
141 public void setIoRatio(int ioRatio) {
142 if (ioRatio <= 0 || ioRatio > 100) {
143 throw new IllegalArgumentException("ioRatio: " + ioRatio + " (expected: 0 < ioRatio <= 100)");
144 }
145 }
146
147 @Override
148 protected EventLoop newChild(Executor executor, Object... args) throws Exception {
149 EventLoopTaskQueueFactory queueFactory = args.length == 4 ? (EventLoopTaskQueueFactory) args[3] : null;
150 return new EpollEventLoop(this, executor, (Integer) args[0],
151 ((SelectStrategyFactory) args[1]).newSelectStrategy(),
152 (RejectedExecutionHandler) args[2], queueFactory);
153 }
154 }
155