本文整理匯總了Java中org.apache.mina.core.buffer.IoBuffer.capacity方法的典型用法代碼示例。如果您正苦於以下問題:Java IoBuffer.capacity方法的具體用法?Java IoBuffer.capacity怎麽用?Java IoBuffer.capacity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.mina.core.buffer.IoBuffer
的用法示例。
在下文中一共展示了IoBuffer.capacity方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: write
import org.apache.mina.core.buffer.IoBuffer; //導入方法依賴的package包/類
/**
* Writes <code>data</code> {@link IoBuffer} to the <code>buf</code>
* {@link IoBuffer} which buffers write requests for the
* <code>session</code> {@ link IoSession} until buffer is full
* or manually flushed.
*
* @param session the session where buffer will be written
* @param data the data to buffer
* @param buf the buffer where data will be temporarily written
*/
private void write(IoSession session, IoBuffer data, IoBuffer buf) {
try {
int len = data.remaining();
if (len >= buf.capacity()) {
/*
* If the request length exceeds the size of the output buffer,
* flush the output buffer and then write the data directly.
*/
NextFilter nextFilter = session.getFilterChain().getNextFilter(this);
internalFlush(nextFilter, session, buf);
nextFilter.filterWrite(session, new DefaultWriteRequest(data));
return;
}
if (len > (buf.limit() - buf.position())) {
internalFlush(session.getFilterChain().getNextFilter(this), session, buf);
}
synchronized (buf) {
buf.put(data);
}
} catch (Throwable e) {
session.getFilterChain().fireExceptionCaught(e);
}
}