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    *   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  package io.netty.channel.oio;
17  
18  
19  import io.netty.channel.Channel;
20  import io.netty.channel.ChannelException;
21  import io.netty.channel.ChannelPromise;
22  import io.netty.channel.EventLoop;
23  import io.netty.channel.EventLoopGroup;
24  import io.netty.channel.ThreadPerChannelEventLoopGroup;
25  
26  import java.util.concurrent.Executors;
27  import java.util.concurrent.ThreadFactory;
28  
29  /**
30   * {@link EventLoopGroup} which is used to handle OIO {@link Channel}'s. Each {@link Channel} will be handled by its
31   * own {@link EventLoop} to not block others.
32   */
33  public class OioEventLoopGroup extends ThreadPerChannelEventLoopGroup {
34  
35      /**
36       * Create a new {@link OioEventLoopGroup} with no limit in place.
37       */
38      public OioEventLoopGroup() {
39          this(0);
40      }
41  
42      /**
43       * Create a new {@link OioEventLoopGroup}.
44       *
45       * @param maxChannels       the maximum number of channels to handle with this instance. Once you try to register
46       *                          a new {@link Channel} and the maximum is exceed it will throw an
47       *                          {@link ChannelException} on the {@link #register(Channel)} and
48       *                          {@link #register(Channel, ChannelPromise)} method.
49       *                          Use {@code 0} to use no limit
50       */
51      public OioEventLoopGroup(int maxChannels) {
52          this(maxChannels, Executors.defaultThreadFactory());
53      }
54  
55      /**
56       * Create a new {@link OioEventLoopGroup}.
57       *
58       * @param maxChannels       the maximum number of channels to handle with this instance. Once you try to register
59       *                          a new {@link Channel} and the maximum is exceed it will throw an
60       *                          {@link ChannelException} on the {@link #register(Channel)} and
61       *                          {@link #register(Channel, ChannelPromise)} method.
62       *                          Use {@code 0} to use no limit
63       * @param threadFactory     the {@link ThreadFactory} used to create new {@link Thread} instances that handle the
64       *                          registered {@link Channel}s
65       */
66      public OioEventLoopGroup(int maxChannels, ThreadFactory threadFactory) {
67          super(maxChannels, threadFactory);
68      }
69  }