001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.mina.core.write; 021 022import org.apache.mina.core.session.IoSession; 023 024/** 025 * Stores {@link WriteRequest}s which are queued to an {@link IoSession}. 026 * 027 * @author <a href="http://mina.apache.org">Apache MINA Project</a> 028 */ 029public interface WriteRequestQueue { 030 031 /** 032 * Get the first request available in the queue for a session. 033 * @param session The session 034 * @return The first available request, if any. 035 */ 036 WriteRequest poll(IoSession session); 037 038 /** 039 * Add a new WriteRequest to the session write's queue 040 * @param session The session 041 * @param writeRequest The writeRequest to add 042 */ 043 void offer(IoSession session, WriteRequest writeRequest); 044 045 /** 046 * Tells if the WriteRequest queue is empty or not for a session 047 * @param session The session to check 048 * @return <tt>true</tt> if the writeRequest is empty 049 */ 050 boolean isEmpty(IoSession session); 051 052 /** 053 * Removes all the requests from this session's queue. 054 * @param session The associated session 055 */ 056 void clear(IoSession session); 057 058 /** 059 * Disposes any releases associated with the specified session. 060 * This method is invoked on disconnection. 061 * @param session The associated session 062 */ 063 void dispose(IoSession session); 064 065 /** 066 * @return the number of objects currently stored in the queue. 067 */ 068 int size(); 069}