net.sf.zig_project.gpl.common.queue
Interface SealableQueue

All Superinterfaces:
Queue
All Known Implementing Classes:
LinearDispatchQueue

public interface SealableQueue
extends Queue

A Sealable Queue may be sealed to prevent further elements from being added. Once sealed, the Queue will also behave in a non-blocking fashion. Removal operations that might have blocked on an empty Queue are expected to return immediately. Unless otherwise specified, implementations can be expected to be unsealed when first created. Add opertions to a SealedQueue should throw a SealedQueueException.

Implementations of this class are expected to be derived from Blocking Queues, such as OrderedBlockingQueue, and not from non-Blocking Queues, like OrderedQueue.

Version:
October 24, 2004
Author:
Frank Ziglar

Method Summary
 boolean isSealed()
          Determines if the Queue is sealed.
 void seal()
          Seals the Queue.
 void unseal()
          Unseals the Queue.
 
Methods inherited from interface net.sf.zig_project.gpl.common.queue.Queue
clear, contains, elements, isEmpty, remove
 

Method Detail

seal

public void seal()
Seals the Queue. If this Queue is empty, and has threads currently waiting in removal operations, this method will wake them up, and they will normally return shortly after. If the Queue has already been sealed, this method does nothing.


isSealed

public boolean isSealed()
Determines if the Queue is sealed.

Returns:
true if the Queue is currently Sealed, false otherwise

unseal

public void unseal()
Unseals the Queue. Subsequent add operations will be allowed to operate normally, and removal operations will revert to their default (potentially blocking) operation. If the Queue is not currently sealed, this call does nothing.

This method is provided as it improves flexibility with a minimum if additional difficulty. That is, reliance on this method may not be a good design. For example, if another thread is currently blocking in a remove operation, no guarantees are made that it will return immediately if the Queue is quickly sealed and then unsealed.