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