|
JThreadKitTM v1.1.0 ( public members only)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.jthreadkit.AbstractSizeMonitored
|
+--com.jthreadkit.fifo.AbstractFIFO
|
+--com.jthreadkit.fifo.AbstractObjectFIFO
Partial implementation of ObjectFIFO.
| Method Summary | |
void |
add(Object obj)
Adds the specified object to the FIFO. |
boolean |
add(Object obj,
long msTimeout)
Adds the specified object to the FIFO. |
void |
addEach(Object[] list)
Adds each of the objects in the array to the FIFO as individual elements. |
void |
addEach(Object[] list,
int offset,
int length)
Adds some of the objects in the array to the FIFO as individual elements starting at the specifed offset and continuing for length elements. |
int |
addEach(Object[] list,
int offset,
int length,
long msTimeout)
Adds some of the objects in the array to the FIFO as individual elements starting at the specifed offset and continuing for length elements. |
int |
addEach(Object[] list,
long msTimeout)
Adds each of the objects in the array to the FIFO as individual elements. |
Class |
getElementType()
Returns the type of items that can be stored in this FIFO. |
Object |
peek()
Returns the next item that will be removed--without removing it from the FIFO. |
Object[] |
peek(int atLeast,
int atMost)
The same as remove(int, int) except that
the items are not removed from the FIFO. |
Object[] |
peek(int atLeast,
int atMost,
long msTimeout)
The same as remove(int, int, long) except that the items
are not removed from the FIFO. |
Object |
peek(long msTimeout)
Returns the next item that will be removed--without removing it from the FIFO. |
int |
peek(Object[] dest,
int offset,
int atLeast,
int atMost)
The same as remove(Object[], int, int, int) except that the items
are not removed from the FIFO. |
int |
peek(Object[] dest,
int offset,
int atLeast,
int atMost,
long msTimeout)
The same as remove(Object[], int, int, int, long) except that the items
are not removed from the FIFO. |
Object[] |
peekAll()
Returns a copy of everything currently in the FIFO (without removing the items). |
Object[] |
peekAtLeastOne()
Waits until at least one item is in the FIFO and then returns all of the items (without removing them). |
Object[] |
peekAtLeastOne(long msTimeout)
Waits until at least one item is in the FIFO and then returns all of the items (without removing them). |
Object |
remove()
Removes one item from the FIFO. |
Object[] |
remove(int atLeast,
int atMost)
Wait until atLeast items are available and then remove
up to atMost items from the FIFO. |
Object[] |
remove(int atLeast,
int atMost,
long msTimeout)
Wait until atLeast items are available and then remove
up to atMost items from the FIFO. |
Object |
remove(long msTimeout)
Removes one item from the FIFO. |
int |
remove(Object[] dest,
int offset,
int atLeast,
int atMost)
Wait until atLeast items are available and then remove
up to atMost items from the FIFO. |
int |
remove(Object[] dest,
int offset,
int atLeast,
int atMost,
long msTimeout)
Wait until atLeast items are available and then remove
up to atMost items from the FIFO. |
Object[] |
removeAll()
Removes all the the items currently in the FIFO without blocking. |
Object[] |
removeAtLeastOne()
Waits until at least one item is in the FIFO and then removes and returns all of the items. |
Object[] |
removeAtLeastOne(long msTimeout)
Waits until at least one item is in the FIFO and then removes and returns all of the items. |
int |
setCapacity(int requestedCapacity)
Requests that the capacity be grown or reduced. |
void |
setElementType(Class newType)
Specifies a restriction on the type of objects than can be stored in this FIFO. |
| Methods inherited from class com.jthreadkit.fifo.AbstractFIFO |
skip, skip, skipExactly, skipExactly |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.jthreadkit.fifo.BasicFIFO |
skip, skip, skipExactly, skipExactly |
| 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 |
public void setElementType(Class newType)
throws ClassCastException,
ShutdownException
ObjectFIFOObject.class
and any reference can be stored, but sometimes you might want
to restrict what can be put in.
Note: This is a somewhat expensive operation in most implementations and should be used sparingly.
setElementType in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOnewType - the class to restrict entries to.ClassCastException - if any of the elements already in
the FIFO can't be cast into the specified type. This exception
won't be thrown on empty queues. If this exception is thrown,
the element type reverts back to what it was before and
the FIFO is in the same (non-corrupted) state that it was before
the request.ShutdownException - see explanation.public Class getElementType()
ObjectFIFOObjectFIFO.setElementType(java.lang.Class).getElementType in interface ObjectFIFO
public int setCapacity(int requestedCapacity)
throws ShutdownException
SizeMonitored1,
it is silently increased to 1.
If the requested new capacity is less than the current value
returned from SizeMonitored.getSize(), it is silently increased to
match the current size.
The actual new capacity is returned.
If the implementing class has (virtually) infinite capacity, then
all calls made to this method are effectively ignored and
Integer.MAX_VALUE is returned for the "new" capacity.
The implementation of this method will typically be an expensive
operation, so calls to setCapacity should be used
sparingly.
To trim the capacity down to the current size--but only down
to a minimum of 1, use:
|
int newCapacity = x.setCapacity(0); |
setCapacity in interface SizeMonitoredsetCapacity in class AbstractSizeMonitoredcom.jthreadkit.SizeMonitoredrequestedCapacity - the desired new capacity.
This number is silently increased to minimum of 1
and/or the value returned from SizeMonitored.getSize() if necessary.ShutdownException - see explanation.
public boolean add(Object obj,
long msTimeout)
throws InterruptedException,
TimedOutException,
ShutdownException,
ClassCastException
ObjectFIFOadd in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOmsTimeout - maximum number of milliseconds to wait. Use
ThreadTools.NO_TIMEOUT (or 0) to indicate that
the waiting should never timeout.true if successful, false if
a timeout occurs (and the timeout option is
not set to throw exceptions
[see explanation]).ClassCastException - if the passed object can't be
cast into the type specified. See ObjectFIFO.getElementType().InterruptedException - see explanation.TimedOutException - see explanation.ShutdownException - see explanation.
public void add(Object obj)
throws InterruptedException,
ShutdownException,
ClassCastException
ObjectFIFOadd in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOClassCastException - if the passed object can't be
cast into the type specified. See ObjectFIFO.getElementType().InterruptedException - see explanation.ShutdownException - see explanation.
public int addEach(Object[] list,
long msTimeout)
throws InterruptedException,
TimedOutException,
ShutdownException,
ClassCastException
ObjectFIFOWARNING: If any exception is thrown, an indeterminate number of elements may have been added. The FIFO will remain coherent (will not be corrupted), but you have to examine it to find out exactly what portion (if any) of the list was successfully added before the exception.
addEach in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOmsTimeout - maximum number of milliseconds to wait. Use
ThreadTools.NO_TIMEOUT (or 0) to indicate that
the waiting should never timeout.ClassCastException - if the one of the objects can't be
cast into the type specified. See ObjectFIFO.getElementType().InterruptedException - see explanation.TimedOutException - see explanation.ShutdownException - see explanation.
public void addEach(Object[] list)
throws InterruptedException,
ShutdownException,
ClassCastException
ObjectFIFOWARNING: If any exception is thrown, an indeterminate number of elements may have been added. The FIFO will remain coherent (will not be corrupted), but you have to examine it to find out exactly what portion (if any) of the list was successfully added before the exception.
addEach in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOClassCastException - if the one of the objects can't be
cast into the type specified. See ObjectFIFO.getElementType().InterruptedException - see explanation.ShutdownException - see explanation.
public int addEach(Object[] list,
int offset,
int length,
long msTimeout)
throws InterruptedException,
TimedOutException,
ShutdownException,
ClassCastException
ObjectFIFOlength elements.
WARNING: If any exception is thrown, an indeterminate number of elements may have been added. The FIFO will remain coherent (will not be corrupted), but you have to examine it to find out exactly what portion (if any) of the list was successfully added before the exception.
addEach in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOmsTimeout - maximum number of milliseconds to wait. Use
ThreadTools.NO_TIMEOUT (or 0) to indicate that
the waiting should never timeout.ClassCastException - if the one of the objects can't be
cast into the type specified. See ObjectFIFO.getElementType().InterruptedException - see explanation.TimedOutException - see explanation.ShutdownException - see explanation.
public void addEach(Object[] list,
int offset,
int length)
throws InterruptedException,
ShutdownException,
ClassCastException
ObjectFIFOlength elements.
WARNING: If any exception is thrown, an indeterminate number of elements may have been added. The FIFO will remain coherent (will not be corrupted), but you have to examine it to find out exactly what portion (if any) of the list was successfully added before the exception.
addEach in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOClassCastException - if the one of the objects can't be
cast into the type specified. See ObjectFIFO.getElementType().InterruptedException - see explanation.ShutdownException - see explanation.
public Object remove(long msTimeout)
throws InterruptedException,
ShutdownException,
TimedOutException
ObjectFIFOIf any exception is thrown, the contents of the FIFO are not altered and the FIFO remains coherent (not corrupted).
remove in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOmsTimeout - maximum number of milliseconds to wait. Use
ThreadTools.NO_TIMEOUT (or 0) to indicate that
the waiting should never timeout.null if there was a
timeout. Caution: null can be validly entered
into the FIFO, so in that case, we can't tell if a timeout
occurred or if the null returned was actually
removed from the queue!InterruptedException - see explanation.TimedOutException - see explanation.ShutdownException - see explanation.
public Object remove()
throws InterruptedException,
ShutdownException
ObjectFIFOIf any exception is thrown, the contents of the FIFO are not altered and the FIFO remains coherent (not corrupted).
remove in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOInterruptedException - see explanation.ShutdownException - see explanation.
public Object peek(long msTimeout)
throws InterruptedException,
ShutdownException,
TimedOutException
ObjectFIFOpeek in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOmsTimeout - maximum number of milliseconds to wait. Use
ThreadTools.NO_TIMEOUT (or 0) to indicate that
the waiting should never timeout.null if there was a
timeout. Caution: null can be validly entered
into the FIFO, so in that case, we can't tell if a timeout
occurred or if the null returned was actually
from the queue!InterruptedException - see explanation.TimedOutException - see explanation.ShutdownException - see explanation.
public Object peek()
throws InterruptedException,
ShutdownException
ObjectFIFOpeek in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOInterruptedException - see explanation.ShutdownException - see explanation.
public int remove(Object[] dest,
int offset,
int atLeast,
int atMost,
long msTimeout)
throws InterruptedException,
ShutdownException,
TimedOutException,
ClassCastException
ObjectFIFOatLeast items are available and then remove
up to atMost items from the FIFO. Load these items into
the specified array dest starting at the
specified offset.
The values for atLeast and atMost may
be silently coerced into this range:
|
0 <= atLeast <= atMost <= getCapacity() |
If any exception is thrown, the contents of the FIFO are not altered and the FIFO remains coherent (not corrupted). It is possible that a portion of the destination array is overwritten, but this partial information should be ignored.
remove in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOmsTimeout - maximum number of milliseconds to wait. Use
ThreadTools.NO_TIMEOUT (or 0) to indicate that
the waiting should never timeout.atLeast
see explanationClassCastException - if the one of the stored objects can't be
cast into the type of the dest array.InterruptedException - see explanation.TimedOutException - see explanation.ShutdownException - see explanation.
public int remove(Object[] dest,
int offset,
int atLeast,
int atMost)
throws InterruptedException,
ShutdownException,
ClassCastException
ObjectFIFOatLeast items are available and then remove
up to atMost items from the FIFO. Load these items into
the specified array dest starting at the
specified offset.
The values for atLeast and atMost may
be silently coerced into this range:
|
0 <= atLeast <= atMost <= getCapacity() |
If any exception is thrown, the contents of the FIFO are not altered and the FIFO remains coherent (not corrupted). It is possible that a portion of the destination array is overwritten, but this partial information should be ignored.
remove in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOatLeast
see explanationClassCastException - if the one of the stored objects can't be
cast into the type of the dest array.InterruptedException - see explanation.ShutdownException - see explanation.
public int peek(Object[] dest,
int offset,
int atLeast,
int atMost,
long msTimeout)
throws InterruptedException,
ShutdownException,
TimedOutException,
ClassCastException
ObjectFIFOremove(Object[], int, int, int, long) except that the items
are not removed from the FIFO.peek in interface ObjectFIFO
public int peek(Object[] dest,
int offset,
int atLeast,
int atMost)
throws InterruptedException,
ShutdownException,
ClassCastException
ObjectFIFOremove(Object[], int, int, int) except that the items
are not removed from the FIFO.peek in interface ObjectFIFO
public Object[] remove(int atLeast,
int atMost,
long msTimeout)
throws InterruptedException,
ShutdownException,
TimedOutException
ObjectFIFOatLeast items are available and then remove
up to atMost items from the FIFO.
The values for atLeast and atMost may
be silently coerced into this range:
|
0 <= atLeast <= atMost <= getCapacity() |
If any exception is thrown, the contents of the FIFO are not altered and the FIFO remains coherent (not corrupted).
remove in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOmsTimeout - maximum number of milliseconds to wait. Use
ThreadTools.NO_TIMEOUT (or 0) to indicate that
the waiting should never timeout.atLeast
see explanationInterruptedException - see explanation.TimedOutException - see explanation.ShutdownException - see explanation.
public Object[] remove(int atLeast,
int atMost)
throws InterruptedException,
ShutdownException
ObjectFIFOatLeast items are available and then remove
up to atMost items from the FIFO.
The values for atLeast and atMost may
be silently coerced into this range:
|
0 <= atLeast <= atMost <= getCapacity() |
If any exception is thrown, the contents of the FIFO are not altered and the FIFO remains coherent (not corrupted).
remove in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOatLeast
see explanationInterruptedException - see explanation.ShutdownException - see explanation.
public Object[] peek(int atLeast,
int atMost,
long msTimeout)
throws InterruptedException,
ShutdownException,
TimedOutException
ObjectFIFOremove(int, int, long) except that the items
are not removed from the FIFO.peek in interface ObjectFIFO
public Object[] peek(int atLeast,
int atMost)
throws InterruptedException,
ShutdownException
ObjectFIFOremove(int, int) except that
the items are not removed from the FIFO.peek in interface ObjectFIFO
public Object[] removeAll()
throws ShutdownException
ObjectFIFOremoveAll in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOShutdownException - see explanation.public Object[] peekAll()
ObjectFIFOpeekAll in interface ObjectFIFO
public Object[] removeAtLeastOne(long msTimeout)
throws InterruptedException,
ShutdownException,
TimedOutException
ObjectFIFOIf any exception is thrown, the contents of the FIFO are not altered and the FIFO remains coherent (not corrupted).
removeAtLeastOne in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOmsTimeout - maximum number of milliseconds to wait. Use
ThreadTools.NO_TIMEOUT (or 0) to indicate that
the waiting should never timeout.InterruptedException - see explanation.TimedOutException - see explanation.ShutdownException - see explanation.
public Object[] removeAtLeastOne()
throws InterruptedException,
ShutdownException
ObjectFIFOIf any exception is thrown, the contents of the FIFO are not altered and the FIFO remains coherent (not corrupted).
removeAtLeastOne in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOInterruptedException - see explanation.ShutdownException - see explanation.
public Object[] peekAtLeastOne(long msTimeout)
throws InterruptedException,
ShutdownException,
TimedOutException
ObjectFIFOpeekAtLeastOne in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOmsTimeout - maximum number of milliseconds to wait. Use
ThreadTools.NO_TIMEOUT (or 0) to indicate that
the waiting should never timeout.InterruptedException - see explanation.TimedOutException - see explanation.ShutdownException - see explanation.
public Object[] peekAtLeastOne()
throws InterruptedException,
ShutdownException
ObjectFIFOpeekAtLeastOne in interface ObjectFIFOcom.jthreadkit.fifo.ObjectFIFOInterruptedException - see explanation.ShutdownException - see explanation.
|
JThreadKitTM v1.1.0 ( public members only)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||