1 /* 2 * Copyright 2009 Red Hat, Inc. 3 * 4 * Red Hat licenses this file to you under the Apache License, version 2.0 5 * (the "License"); you may not use this file except in compliance with the 6 * 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 import org.jboss.netty.channel.socket.DatagramChannel; 24 import org.jboss.netty.channel.socket.DatagramChannelConfig; 25 26 /** 27 * A {@link DatagramChannelConfig} for a NIO TCP/IP {@link DatagramChannel}. 28 * 29 * <h3>Available options</h3> 30 * 31 * In addition to the options provided by {@link ChannelConfig} and 32 * {@link DatagramChannelConfig}, {@link NioDatagramChannelConfig} allows the 33 * following options in the option map: 34 * 35 * <table border="1" cellspacing="0" cellpadding="6"> 36 * <tr> 37 * <th>Name</th><th>Associated setter method</th> 38 * </tr><tr> 39 * <td>{@code "writeBufferHighWaterMark"}</td><td>{@link #setWriteBufferHighWaterMark(int)}</td> 40 * </tr><tr> 41 * <td>{@code "writeBufferLowWaterMark"}</td><td>{@link #setWriteBufferLowWaterMark(int)}</td> 42 * </tr><tr> 43 * <td>{@code "writeSpinCount"}</td><td>{@link #setWriteSpinCount(int)}</td> 44 * </tr><tr> 45 * </table> 46 * 47 * @author <a href="http://www.jboss.org/netty/">The Netty Project</a> 48 * @author <a href="http://gleamynode.net/">Trustin Lee</a> 49 * @author Daniel Bevenius (dbevenius@jboss.com) 50 * 51 * @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $ 52 */ 53 public interface NioDatagramChannelConfig extends DatagramChannelConfig { 54 55 /** 56 * Returns the high water mark of the write buffer. If the number of bytes 57 * queued in the write buffer exceeds this value, {@link Channel#isWritable()} 58 * will start to return {@code true}. 59 */ 60 int getWriteBufferHighWaterMark(); 61 62 /** 63 * Sets the high water mark of the write buffer. If the number of bytes 64 * queued in the write buffer exceeds this value, {@link Channel#isWritable()} 65 * will start to return {@code true}. 66 */ 67 void setWriteBufferHighWaterMark(int writeBufferHighWaterMark); 68 69 /** 70 * Returns the low water mark of the write buffer. Once the number of bytes 71 * queued in the write buffer exceeded the 72 * {@linkplain #setWriteBufferHighWaterMark(int) high water mark} and then 73 * dropped down below this value, {@link Channel#isWritable()} will return 74 * {@code false} again. 75 */ 76 int getWriteBufferLowWaterMark(); 77 78 /** 79 * Sets the low water mark of the write buffer. Once the number of bytes 80 * queued in the write buffer exceeded the 81 * {@linkplain #setWriteBufferHighWaterMark(int) high water mark} and then 82 * dropped down below this value, {@link Channel#isWritable()} will return 83 * {@code false} again. 84 */ 85 void setWriteBufferLowWaterMark(int writeBufferLowWaterMark); 86 87 /** 88 * Returns the maximum loop count for a write operation until 89 * {@link WritableByteChannel#write(ByteBuffer)} returns a non-zero value. 90 * It is similar to what a spin lock is used for in concurrency programming. 91 * It improves memory utilization and write throughput depending on 92 * the platform that JVM runs on. The default value is {@code 16}. 93 */ 94 int getWriteSpinCount(); 95 96 /** 97 * Sets the maximum loop count for a write operation until 98 * {@link WritableByteChannel#write(ByteBuffer)} returns a non-zero value. 99 * It is similar to what a spin lock is used for in concurrency programming. 100 * It improves memory utilization and write throughput depending on 101 * the platform that JVM runs on. The default value is {@code 16}. 102 * 103 * @throws IllegalArgumentException 104 * if the specified value is {@code 0} or less than {@code 0} 105 */ 106 void setWriteSpinCount(int writeSpinCount); 107 }