org.objectweb.dream.queue
Interface Buffer

All Known Implementing Classes:
AbstractBufferImpl

public interface Buffer

This interface defines methods that must be implemented by a buffer. Buffers are used to store messages. It is possible to

Note 1: all the messages that are stored in a buffer are not always available for removal (e.g. when the buffer implements an ordering policy).

Note 2: the different indicators (stored messages, available space, and available messages) have no predetermined semantics: the indicator can be a number of messages, a number of bytes, etc.


Field Summary
static String ITF_NAME
          The commonly used name to refer to this interface.
 
Method Summary
 void add(Message message)
          Adds the specified message to the buffer.
 int availableMessagesIndicator()
          Returns an indicator on available messages.
 int availableSpaceIndicator()
          Returns an indicator on available space.
 Message get()
          Gets a message from the buffer.
 Message remove()
          Removes a message from the buffer.
 int storedMessagesIndicator()
          Returns an indicator on stored messages.
 

Field Detail

ITF_NAME

public static final String ITF_NAME
The commonly used name to refer to this interface.

See Also:
Constant Field Values
Method Detail

storedMessagesIndicator

public int storedMessagesIndicator()
Returns an indicator on stored messages. The semantic of this indicator depends on the buffer implementation. Typical examples of indicators are the number of messages, the number of bytes, etc.

Returns:
an indicator on stored messages.

availableMessagesIndicator

public int availableMessagesIndicator()
Returns an indicator on available messages. The semantic of this indicator depends on the buffer implementation. Typical examples of indicators are the number of messages, the number of bytes, etc.

Returns:
an indicator on available messages.

availableSpaceIndicator

public int availableSpaceIndicator()
Returns an indicator on available space. The semantic of this indicator depends on the buffer implementation. Typical examples of indicators are the number of messages, the number of bytes, etc. Note: when the buffer has no maximum storage capabilities, this method must return Integer.MAX_VALUE.

Returns:
an indicator on available space.

add

public void add(Message message)
         throws InterruptedException
Adds the specified message to the buffer. This method may block if there is not enough space available.

Buffers may place limitations on what elements may be added to this buffer. In particular, some buffers require that messages contain particular chunks.

Parameters:
message - message to be addedto be appended to this list.
Throws:
InterruptedException - if it is interrupted while adding the message.

remove

public Message remove()
               throws InterruptedException
Removes a message from the buffer. This method blocks if availableMessagesIndicator()returns 0.

Returns:
a message.
Throws:
InterruptedException - if it is interrupted while removing a message.

get

public Message get()
            throws InterruptedException
Gets a message from the buffer. This method blocks if availableMessagesIndicator()returns 0.

Returns:
a message.
Throws:
InterruptedException - if it is interrupted while removing a message.


Copyright © 2003, 2004 - INRIA Rhone-Alpes - All Rights Reserved.