View Javadoc
1   /*
2    * Copyright 2013 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    *   http://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  
17  package io.netty.channel;
18  
19  import io.netty.util.concurrent.EventExecutorGroup;
20  
21  /**
22   * Special {@link EventExecutorGroup} which allows registering {@link Channel}s that get
23   * processed for later selection during the event loop.
24   */
25  public interface EventLoopGroup extends EventExecutorGroup {
26      @Override
27      EventLoop next();
28  
29      /**
30       * Register a {@link Channel} with an {@link EventLoop} from this {@link EventLoopGroup}. The returned
31       * {@link ChannelFuture} will get notified once the registration is completed.
32       * <p>
33       * It's only safe to submit a new task to the {@link EventLoop} from within a
34       * {@link ChannelHandler} once the {@link ChannelPromise} succeeded. Otherwise
35       * the task may or may not be rejected.
36       * </p>
37       */
38      ChannelFuture register(Channel channel);
39  
40      /**
41       * Register a {@link Channel} with an {@link EventLoop} from this {@link EventLoopGroup}. The provided
42       * {@link ChannelPromise} will get notified once the registration is completed. The returned {@link ChannelFuture}
43       * is the same {@link ChannelPromise} that was passed to the method.
44       * <p>
45       * It's only safe to submit a new task to the {@link EventLoop} from within a
46       * {@link ChannelHandler} once the {@link ChannelPromise} succeeded. Otherwise
47       * the task may or may not be rejected.
48       * </p>
49       */
50      ChannelFuture register(Channel channel, ChannelPromise promise);
51  }