View Javadoc
1   /*
2    * Copyright 2014 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.channel.epoll;
17  
18  import io.netty.channel.Channel;
19  import io.netty.channel.EventLoopTaskQueueFactory;
20  import io.netty.channel.IoEventLoopGroup;
21  import io.netty.channel.IoHandlerFactory;
22  import io.netty.channel.SingleThreadIoEventLoop;
23  import io.netty.util.concurrent.RejectedExecutionHandler;
24  
25  import java.util.Iterator;
26  import java.util.Queue;
27  import java.util.concurrent.Executor;
28  import java.util.concurrent.ThreadFactory;
29  
30  /**
31   * @deprecated Use {@link SingleThreadIoEventLoop} with {@link EpollIoHandler}
32   */
33  @Deprecated
34  public class EpollEventLoop extends SingleThreadIoEventLoop {
35  
36      EpollEventLoop(IoEventLoopGroup parent, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory) {
37          super(parent, threadFactory, ioHandlerFactory);
38      }
39  
40      EpollEventLoop(IoEventLoopGroup parent, Executor executor, IoHandlerFactory ioHandlerFactory) {
41          super(parent, executor, ioHandlerFactory);
42      }
43  
44      EpollEventLoop(IoEventLoopGroup parent, Executor executor, IoHandlerFactory ioHandlerFactory,
45                     EventLoopTaskQueueFactory taskQueueFactory,
46                     EventLoopTaskQueueFactory tailTaskQueueFactory,
47                     RejectedExecutionHandler rejectedExecutionHandler) {
48          super(parent, executor, ioHandlerFactory, newTaskQueue(taskQueueFactory), newTaskQueue(tailTaskQueueFactory),
49                  rejectedExecutionHandler);
50      }
51  
52      private static Queue<Runnable> newTaskQueue(
53              EventLoopTaskQueueFactory queueFactory) {
54          if (queueFactory == null) {
55              return newTaskQueue0(DEFAULT_MAX_PENDING_TASKS);
56          }
57          return queueFactory.newTaskQueue(DEFAULT_MAX_PENDING_TASKS);
58      }
59  
60      @Override
61      public int registeredChannels() {
62          return ((EpollIoHandler) ioHandler()).numRegisteredChannels();
63      }
64  
65      @Override
66      public Iterator<Channel> registeredChannelsIterator() {
67          return ((EpollIoHandler) ioHandler()).registeredChannelsList().iterator();
68      }
69  
70  }