JThreadKitTM
v1.1.0
(public members only)

com.jthreadkit.fifo
Interface BasicFIFO

All Superinterfaces:
AccessibleLock, SimpleShutdown, SizeMonitored, TimedOutExceptionOption
All Known Subinterfaces:
ObjectFIFO
All Known Implementing Classes:
AbstractFIFO

public interface BasicFIFO
extends SizeMonitored

This high-level interface is a common ancestor of all the FIFO implementations. The generic "skip" funtionality is implemented here.

InterruptedException - can be thrown from many of the methods in this class. If one thread is blocked inside one of these methods and another thread interrupts it, InterruptedException is thrown by the blocked thread.

TimedOutException - can be thrown from many of the methods in this class only if the "use TimedOutException" option is set. If true is passed to the setUseTimedOutException() method, the option is set and TimedOutException will be thrown from methods that timeout when the specified timeout period expires. If false is passed, the option is unset and TimedOutException will never be thrown. The TimedOutExceptionOption.isUseTimedOutExceptionSet() method returns true if the option is set and TimedOutException's will be thrown. TimedOutException is a subclass of RuntimeException so there is no need for a try-catch block if the option is not set. This option allows you to determine whether or not a timeout is an exceptional condition in your context (a condition that should result in an exception being thrown). If timeouts are routine, you probably will want to leave this option in its default unset state. See the class description of TimedOutException for more information.

ShutdownException - can be thrown from many of the methods in this class. This exception is not thrown by methods until the SimpleShutdown.shutdown() method is called. If shutdown() is never called, this exception will never be thrown and can be safely ignored. ShutdownException is a subclass of RuntimeException so there is no need for a try-catch block if shutdown() won't be called. After shutdown() is called, any threads that are currently blocked waiting will immediately throw this exception. In addition, any future calls to methods that would either result in waiting or would alter the object cause this exception to be thrown (if no waiting is needed because the condition is already met, this exception will not be thrown). See the class description of ShutdownException for more information.


Method Summary
 int skip(int atMost)
          Skips (deletes) items from the FIFO up to the maximum specified.
 int skip(int atMost, long msTimeout)
          Skips (deletes) items from the FIFO up to the maximum specified.
 void skipExactly(int exactCount)
          Skips (deletes) items from the FIFO exactly matching the count specified.
 int skipExactly(int exactCount, long msTimeout)
          Skips (deletes) items from the FIFO exactly matching the count specified if no timeout occurs.
 
Methods inherited from interface com.jthreadkit.SizeMonitored
addSizeChangeListener, getCapacity, getSize, isEmpty, isFull, removeSizeChangeListener, setCapacity, shutdownWhenEmpty, waitForSizeToChange, waitForSizeToChange, waitForSizeToClimbTo, waitForSizeToClimbTo, waitForSizeToFallTo, waitForSizeToFallTo, waitUntilEmpty, waitUntilEmpty, waitUntilFull, waitUntilFull, waitUntilSizeInRange, waitUntilSizeInRange, waitUntilSizeIs, waitUntilSizeIs, waitWhileEmpty, waitWhileEmpty, waitWhileFull, waitWhileFull, waitWhileSizeInRange, waitWhileSizeInRange, waitWhileSizeIs, waitWhileSizeIs
 
Methods inherited from interface com.jthreadkit.AccessibleLock
getLockObject
 
Methods inherited from interface com.jthreadkit.SimpleShutdown
shutdown
 
Methods inherited from interface com.jthreadkit.TimedOutExceptionOption
isUseTimedOutExceptionSet, setUseTimedOutException
 

Method Detail

skip

public int skip(int atMost,
                long msTimeout)
         throws InterruptedException,
                TimedOutException,
                ShutdownException
Skips (deletes) items from the FIFO up to the maximum specified. If a timeout occurs, all of the items in the FIFO will be skipped even though this is less than atMost.
Parameters:
atMost - the number of items to potentially skip. This is silently reduced to getCapacity() so specifying values larger than the capacity will have no effect.
msTimeout - maximum number of milliseconds to wait. Use ThreadTools.NO_TIMEOUT (or 0) to indicate that the waiting should never timeout.
Returns:
the number of items actually skipped; this may be less than atMost. If a timeout occurs, 0 may be returned or some other number smaller than atMost.
Throws:
InterruptedException - see explanation.
TimedOutException - see explanation.
ShutdownException - see explanation.

skip

public int skip(int atMost)
         throws InterruptedException,
                ShutdownException
Skips (deletes) items from the FIFO up to the maximum specified.
Parameters:
atMost - the number of items to potentially skip. This is silently reduced to getCapacity() so specifying values larger than the capacity will have no effect.
Returns:
the number of items actually skipped; this may be less than atMost.
Throws:
InterruptedException - see explanation.
ShutdownException - see explanation.

skipExactly

public int skipExactly(int exactCount,
                       long msTimeout)
                throws InterruptedException,
                       TimedOutException,
                       ShutdownException
Skips (deletes) items from the FIFO exactly matching the count specified if no timeout occurs. If a timeout occurs, all of the items in the FIFO will be skipped even though this is less than atMost.
Parameters:
exactCount - the number of items to skip. This is not silently reduced. This number can be greater than the capacity.
msTimeout - maximum number of milliseconds to wait. Use ThreadTools.NO_TIMEOUT (or 0) to indicate that the waiting should never timeout.
Returns:
the number of items actually skipped; this may be less than atMost if a timeout occured.
Throws:
InterruptedException - see explanation.
TimedOutException - see explanation.
ShutdownException - see explanation.

skipExactly

public void skipExactly(int exactCount)
                 throws InterruptedException,
                        ShutdownException
Skips (deletes) items from the FIFO exactly matching the count specified.
Parameters:
exactCount - the number of items to skip. This is not silently reduced. This number can be greater than the capacity.
Throws:
InterruptedException - see explanation.
ShutdownException - see explanation.

JThreadKitTM
v1.1.0
(public members only)

© Copyright 2000-2001 Programix Incorporated. All rights reserved. JThreadKit home