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  import io.netty.util.internal.logging.InternalLogger;
25  import io.netty.util.internal.logging.InternalLoggerFactory;
26  
27  import java.util.Iterator;
28  import java.util.Queue;
29  import java.util.concurrent.Executor;
30  import java.util.concurrent.ThreadFactory;
31  
32  /**
33   * @deprecated Use {@link SingleThreadIoEventLoop} with {@link EpollIoHandler}
34   */
35  @Deprecated
36  public class EpollEventLoop extends SingleThreadIoEventLoop {
37  
38      private static final InternalLogger LOGGER = InternalLoggerFactory.getInstance(EpollEventLoop.class);
39  
40      EpollEventLoop(IoEventLoopGroup parent, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory) {
41          super(parent, threadFactory, ioHandlerFactory);
42      }
43  
44      EpollEventLoop(IoEventLoopGroup parent, Executor executor, IoHandlerFactory ioHandlerFactory) {
45          super(parent, executor, ioHandlerFactory);
46      }
47  
48      EpollEventLoop(IoEventLoopGroup parent, Executor executor, IoHandlerFactory ioHandlerFactory,
49                     EventLoopTaskQueueFactory taskQueueFactory,
50                     EventLoopTaskQueueFactory tailTaskQueueFactory,
51                     RejectedExecutionHandler rejectedExecutionHandler) {
52          super(parent, executor, ioHandlerFactory, newTaskQueue(taskQueueFactory), newTaskQueue(tailTaskQueueFactory),
53                  rejectedExecutionHandler);
54      }
55  
56      private static Queue<Runnable> newTaskQueue(
57              EventLoopTaskQueueFactory queueFactory) {
58          if (queueFactory == null) {
59              return newTaskQueue0(DEFAULT_MAX_PENDING_TASKS);
60          }
61          return queueFactory.newTaskQueue(DEFAULT_MAX_PENDING_TASKS);
62      }
63  
64      @Override
65      public int registeredChannels() {
66          return ((EpollIoHandler) ioHandler()).numRegisteredChannels();
67      }
68  
69      @Override
70      public Iterator<Channel> registeredChannelsIterator() {
71          return ((EpollIoHandler) ioHandler()).registeredChannelsList().iterator();
72      }
73  
74      /**
75       * Returns 0.
76       */
77      public int getIoRatio() {
78          return 0;
79      }
80  
81      /**
82       * This method is a no-op.
83       *
84       * @deprecated
85       */
86      @Deprecated
87      public void setIoRatio(int ioRatio) {
88          LOGGER.debug("EpollEventLoop.setIoRatio(int) logic was removed, this is a no-op");
89      }
90  }