• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java WriteRequestQueue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.mina.core.write.WriteRequestQueue的典型用法代码示例。如果您正苦于以下问题:Java WriteRequestQueue类的具体用法?Java WriteRequestQueue怎么用?Java WriteRequestQueue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WriteRequestQueue类属于org.apache.mina.core.write包,在下文中一共展示了WriteRequestQueue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: clearWriteRequestQueue

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
private void clearWriteRequestQueue(S session, IOException ioe) {
	WriteRequestQueue writeRequestQueue = session.getWriteRequestQueue();
	WriteRequest req = session.getCurrentWriteRequest();
	if (req == null) {
		req = writeRequestQueue.poll();
		if (req == null) {
			return;
		}
	} else {
		session.setCurrentWriteRequest(null);
	}

	// Create an exception and notify.
	Throwable cause = (ioe != null ? new WriteToClosedSessionException(ioe) : new WriteToClosedSessionException());

	do {
		req.getFuture().setException(cause);

		Object message = req.getMessage();
		if (message instanceof IoBuffer) {
			((IoBuffer) message).free();
		}
	} while ((req = writeRequestQueue.poll()) != null);

	session.getFilterChain().fireExceptionCaught(cause);
}
 
开发者ID:dwing4g,项目名称:jane,代码行数:27,代码来源:AbstractPollingIoProcessor.java


示例2: write

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void write(VmPipeSession session, WriteRequest writeRequest) {
    WriteRequestQueue writeRequestQueue = session.getWriteRequestQueue();

    writeRequestQueue.offer(session, writeRequest);

    if (!session.isWriteSuspended()) {
        this.flush(session);
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:13,代码来源:VmPipeFilterChain.java


示例3: getWriteRequestQueue

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public final WriteRequestQueue getWriteRequestQueue() {
    if (writeRequestQueue == null) {
        throw new IllegalStateException();
    }
    return writeRequestQueue;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:10,代码来源:AbstractIoSession.java


示例4: write

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void write(S session, WriteRequest writeRequest) {
    WriteRequestQueue writeRequestQueue = session.getWriteRequestQueue();

    writeRequestQueue.offer(session, writeRequest);

    if (!session.isWriteSuspended()) {
        this.flush(session);
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:13,代码来源:AbstractPollingIoProcessor.java


示例5: filterWrite

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void filterWrite(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception {

    AbstractIoSession s = (AbstractIoSession) session;

    // Maintain counters.
    if (writeRequest.getMessage() instanceof IoBuffer) {
        IoBuffer buffer = (IoBuffer) writeRequest.getMessage();
        // I/O processor implementation will call buffer.reset()
        // it after the write operation is finished, because
        // the buffer will be specified with messageSent event.
        buffer.mark();
        int remaining = buffer.remaining();

        if (remaining == 0) {
            // Zero-sized buffer means the internal message
            // delimiter.
            s.increaseScheduledWriteMessages();
        } else {
            s.increaseScheduledWriteBytes(remaining);
        }
    } else {
        s.increaseScheduledWriteMessages();
    }

    WriteRequestQueue writeRequestQueue = s.getWriteRequestQueue();

    if (!s.isWriteSuspended()) {
        if (writeRequestQueue.size() == 0) {
            // We can write directly the message
            s.getProcessor().write(s, writeRequest);
        } else {
            s.getWriteRequestQueue().offer(s, writeRequest);
            s.getProcessor().flush(s);
        }
    } else {
        s.getWriteRequestQueue().offer(s, writeRequest);
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:41,代码来源:DefaultIoFilterChain.java


示例6: getWriteRequestQueue0

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
WriteRequestQueue getWriteRequestQueue0() {
    return super.getWriteRequestQueue();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:4,代码来源:VmPipeSession.java


示例7: CloseAwareWriteQueue

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public CloseAwareWriteQueue(WriteRequestQueue queue) {
    this.queue = queue;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:7,代码来源:AbstractIoSession.java


示例8: getWriteRequestQueue

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
public WriteRequestQueue getWriteRequestQueue(IoSession session) throws Exception {
    return new DefaultWriteRequestQueue();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:4,代码来源:DefaultIoSessionDataStructureFactory.java


示例9: flush

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
private boolean flush( S session, long currentTime ) throws Exception
{
    final WriteRequestQueue writeRequestQueue = session.getWriteRequestQueue();
    final int maxWrittenBytes = session.getConfig().getMaxReadBufferSize()
        + ( session.getConfig().getMaxReadBufferSize() >>> 1 );

    int writtenBytes = 0;

    try
    {
        for ( ;; )
        {
            WriteRequest req = session.getCurrentWriteRequest();

            if ( req == null )
            {
                req = writeRequestQueue.poll( session );

                if ( req == null )
                {
                    setInterestedInWrite( session, false );
                    break;
                }

                session.setCurrentWriteRequest( req );
            }

            IoBuffer buf = ( IoBuffer ) req.getMessage();

            if ( buf.remaining() == 0 )
            {
                // Clear and fire event
                session.setCurrentWriteRequest( null );
                buf.reset();
                session.getFilterChain().fireMessageSent( req );
                continue;
            }

            SocketAddress destination = req.getDestination();

            if ( destination == null )
            {
                destination = session.getRemoteAddress();
            }

            int localWrittenBytes = send( session, buf, destination );

            if ( ( localWrittenBytes == 0 ) || ( writtenBytes >= maxWrittenBytes ) )
            {
                // Kernel buffer is full or wrote too much
                setInterestedInWrite( session, true );

                return false;
            }
            else
            {
                setInterestedInWrite( session, false );

                // Clear and fire event
                session.setCurrentWriteRequest( null );
                writtenBytes += localWrittenBytes;
                buf.reset();
                session.getFilterChain().fireMessageSent( req );
            }
        }
    }
    finally
    {
        session.increaseWrittenBytes( writtenBytes, currentTime );
    }

    return true;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:74,代码来源:AbstractPollingConnectionlessIoAcceptor.java


示例10: getWriteRequestQueue

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
@Override
public WriteRequestQueue getWriteRequestQueue() {
    return null;
}
 
开发者ID:icelemon1314,项目名称:mapleLemon,代码行数:5,代码来源:MockIOSession.java


示例11: getWriteRequestQueue

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
@Override
public WriteRequestQueue getWriteRequestQueue() {
	throw new UnsupportedOperationException("Not supported yet.");
}
 
开发者ID:316181444,项目名称:Hxms,代码行数:5,代码来源:MockIOSession.java


示例12: getWriteRequestQueue

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
@Override
public WriteRequestQueue getWriteRequestQueue() {
    // TODO Auto-generated method stub
    return null;
}
 
开发者ID:Red5,项目名称:red5-websocket,代码行数:6,代码来源:WebSocketServerTest.java


示例13: getWriteRequestQueue

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
@Override
public WriteRequestQueue getWriteRequestQueue(IoSession session)
{
	_wrqCount.getAndIncrement();
	return new WriteRequestQueue()
	{
		private final ArrayDeque<WriteRequest> _wrq = new ArrayDeque<>();

		@Override
		public synchronized int size()
		{
			return _wrq.size();
		}

		@Override
		public synchronized boolean isEmpty()
		{
			return _wrq.isEmpty();
		}

		@Override
		public synchronized void clear()
		{
			_wrq.clear();
		}

		@Override
		public WriteRequest poll()
		{
			WriteRequest wr;
			synchronized(this)
			{
				wr = _wrq.pollFirst();
			}
			if(wr == AbstractIoSession.CLOSE_REQUEST)
			{
				wr = null;
				session.closeNow();
				dispose();
			}
			return wr;
		}

		@Override
		public synchronized void offer(WriteRequest writeRequest) // message must be IoBuffer or FileRegion
		{
			_wrq.addLast(writeRequest);
		}

		@Override
		public void dispose()
		{
		}

		@Override
		public synchronized String toString()
		{
			return _wrq.toString();
		}
	};
}
 
开发者ID:dwing4g,项目名称:jane,代码行数:62,代码来源:TestEcho.java


示例14: getWriteRequestQueue

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
@Override
public final WriteRequestQueue getWriteRequestQueue() {
	return writeRequestQueue;
}
 
开发者ID:dwing4g,项目名称:jane,代码行数:5,代码来源:AbstractIoSession.java


示例15: getWriteRequestQueue

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
@Override
public WriteRequestQueue getWriteRequestQueue(IoSession session) {
	return new DefaultWriteRequestQueue(session);
}
 
开发者ID:dwing4g,项目名称:jane,代码行数:5,代码来源:DefaultIoSessionDataStructureFactory.java


示例16: getWriteRequestQueue

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
/**
    * @see IoSession#getWriteRequestQueue()
    */
   public WriteRequestQueue getWriteRequestQueue() {
return wrappedSession.getWriteRequestQueue();
   }
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:7,代码来源:FtpIoSession.java


示例17: getWriteRequestQueue

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
/**
 * TODO Add method documentation
 */
WriteRequestQueue getWriteRequestQueue();
 
开发者ID:eclipse,项目名称:neoscada,代码行数:5,代码来源:IoSession.java


示例18: setWriteRequestQueue

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
/**
 * Create a new close aware write queue, based on the given write queue.
 *
 * @param writeRequestQueue
 *            The write request queue
 */
public final void setWriteRequestQueue(WriteRequestQueue writeRequestQueue) {
    this.writeRequestQueue = new CloseAwareWriteQueue(writeRequestQueue);
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:10,代码来源:AbstractIoSession.java


示例19: getWriteRequestQueue

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
/**
 * Returns an {@link WriteRequest} which is going to be associated with
 * the specified <tt>session</tt>.  Please note that the returned
 * implementation must be thread-safe and robust enough to deal
 * with various messages types (even what you didn't expect at all),
 * especially when you are going to implement a priority queue which
 * involves {@link Comparator}.
 */
WriteRequestQueue getWriteRequestQueue(IoSession session) throws Exception;
 
开发者ID:eclipse,项目名称:neoscada,代码行数:10,代码来源:IoSessionDataStructureFactory.java


示例20: getWriteRequestQueue

import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
/**
 * Get the queue that contains the message waiting for being written.
 * As the reader might not be ready, it's frequent that the messages aren't written completely,
 * or that some older messages are waiting to be written when a new message arrives.
 * This queue is used to manage the backlog of messages.
 *
 * @return The queue containing the pending messages.
 */
WriteRequestQueue getWriteRequestQueue();
 
开发者ID:dwing4g,项目名称:jane,代码行数:10,代码来源:IoSession.java



注:本文中的org.apache.mina.core.write.WriteRequestQueue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JobStartException类代码示例发布时间:2022-05-22
下一篇:
Java RelativeTimeTextView类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap