View Javadoc
1   /*
2    * Copyright 2012 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.netty5.channel;
17  
18  import io.netty5.util.concurrent.Future;
19  import io.netty5.util.concurrent.OrderedEventExecutor;
20  
21  /**
22   * Will handle all the I/O operations for a {@link IoHandle} once registered.
23   *<p>
24   * One {@link EventLoop} instance will usually handle more than one {@link IoHandle} but this may depend on
25   * implementation details and internals.
26   */
27  public interface EventLoop extends OrderedEventExecutor, EventLoopGroup {
28  
29      @Override
30      default EventLoop next() {
31          return this;
32      }
33  
34      /**
35       * Register the {@link IoHandle} to the {@link EventLoop} for I/O processing.
36       *
37       * @param handle   the {@link IoHandle} to register.
38       * @return          the {@link Future} that is notified once the operations completes.
39       */
40      Future<Void> registerForIo(IoHandle handle);
41  
42      /**
43       * Deregister the {@link Channel} from the {@link EventLoop} for I/O processing.
44       *
45       * @param channel   the {@link IoHandle} to deregister.
46       * @return          the {@link Future} that is notified once the operations completes.
47       */
48      Future<Void> deregisterForIo(IoHandle handle);
49  
50      // Force the implementing class to implement this method itself. This is needed as
51      // EventLoopGroup provides default implementations that call next() which would lead to
52      // and infinite loop if not implemented differently in the EventLoop itself.
53      @Override
54      boolean isCompatible(Class<? extends IoHandle> handleType);
55  }