查看本类的 API文档回源码主页即时通讯网 - 即时通讯开发者社区!
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 org.jboss.netty.channel.socket.nio;
17  
18  import java.nio.ByteBuffer;
19  import java.nio.channels.WritableByteChannel;
20  
21  import org.jboss.netty.channel.Channel;
22  import org.jboss.netty.channel.ChannelConfig;
23  
24  /**
25   * Special {@link ChannelConfig} sub-type which offers extra methods which are useful for NIO.
26   *
27   */
28  public interface NioChannelConfig extends ChannelConfig {
29  
30      /**
31       * Returns the high water mark of the write buffer.  If the number of bytes
32       * queued in the write buffer exceeds this value, {@link Channel#isWritable()}
33       * will start to return {@code false}.
34       */
35      int getWriteBufferHighWaterMark();
36  
37      /**
38       * Sets the high water mark of the write buffer.  If the number of bytes
39       * queued in the write buffer exceeds this value, {@link Channel#isWritable()}
40       * will start to return {@code false}.
41       */
42      void setWriteBufferHighWaterMark(int writeBufferHighWaterMark);
43  
44      /**
45       * Returns the low water mark of the write buffer.  Once the number of bytes
46       * queued in the write buffer exceeded the
47       * {@linkplain #setWriteBufferHighWaterMark(int) high water mark} and then
48       * dropped down below this value, {@link Channel#isWritable()} will start to return
49       * {@code true} again.
50       */
51      int getWriteBufferLowWaterMark();
52  
53      /**
54       * Sets the low water mark of the write buffer.  Once the number of bytes
55       * queued in the write buffer exceeded the
56       * {@linkplain #setWriteBufferHighWaterMark(int) high water mark} and then
57       * dropped down below this value, {@link Channel#isWritable()} will start toreturn
58       * {@code true} again.
59       */
60      void setWriteBufferLowWaterMark(int writeBufferLowWaterMark);
61  
62      /**
63       * Returns the maximum loop count for a write operation until
64       * {@link WritableByteChannel#write(ByteBuffer)} returns a non-zero value.
65       * It is similar to what a spin lock is used for in concurrency programming.
66       * It improves memory utilization and write throughput depending on
67       * the platform that JVM runs on.  The default value is {@code 16}.
68       */
69      int getWriteSpinCount();
70  
71      /**
72       * Sets the maximum loop count for a write operation until
73       * {@link WritableByteChannel#write(ByteBuffer)} returns a non-zero value.
74       * It is similar to what a spin lock is used for in concurrency programming.
75       * It improves memory utilization and write throughput depending on
76       * the platform that JVM runs on.  The default value is {@code 16}.
77       *
78       * @throws IllegalArgumentException
79       *         if the specified value is {@code 0} or less than {@code 0}
80       */
81      void setWriteSpinCount(int writeSpinCount);
82  }