public abstract class ParIteratorAbstract<E> extends java.lang.Object implements ParIterator<E>
ParIterator.Schedule| Modifier and Type | Field and Description |
|---|---|
protected int |
chunkSize |
protected java.util.Collection<E> |
collection |
protected java.util.List<E> |
data |
protected java.util.concurrent.ConcurrentLinkedQueue<ParIteratorException<E>> |
exceptions |
protected Flags |
flags |
protected boolean |
ignoreBarrier |
protected java.util.concurrent.CountDownLatch |
latch |
protected int |
numOfThreads |
protected java.util.concurrent.ConcurrentLinkedQueue<java.util.Iterator<E>> |
reclaimedElements |
protected ThreadID |
threadID |
DEFAULT_CHUNKSIZE| Constructor and Description |
|---|
ParIteratorAbstract(java.util.Collection<E> collection,
int chunkSize,
int numOfThreads,
boolean ignoreBarrier) |
ParIteratorAbstract(int numOfThreads,
boolean ignoreBarrier) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
allOtherThreadsHaveLocalBreaked(int tid) |
ParIteratorException<E>[] |
getAllExceptions()
Returns all the exceptions that have (so far) occurred during traversal of the Parallel Iterator.
|
int |
getID()
For test.
|
void |
globalBreak()
Causes all threads to stop processing elements at the next iteration boundary.
|
void |
register(java.lang.Exception e)
When a thread encounters an exception during traversal of a Parallel Iterator, the exception is registered using this method.
|
void |
register(java.lang.Exception e,
E currentElements) |
void |
remove()
Removes from the underlying collection the last element returned by the Parallel Iterator to the current thread.
|
void |
reset()
Reset ParIterator for reuse.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithasNext, localBreak, nextprotected int chunkSize
protected final int numOfThreads
protected java.util.concurrent.CountDownLatch latch
protected boolean ignoreBarrier
protected final ThreadID threadID
protected java.util.List<E> data
protected java.util.Collection<E> collection
protected final java.util.concurrent.ConcurrentLinkedQueue<java.util.Iterator<E>> reclaimedElements
protected java.util.concurrent.ConcurrentLinkedQueue<ParIteratorException<E>> exceptions
protected final Flags flags
public ParIteratorAbstract(java.util.Collection<E> collection, int chunkSize, int numOfThreads, boolean ignoreBarrier)
public ParIteratorAbstract(int numOfThreads,
boolean ignoreBarrier)
public void remove()
ParIteratorremove in interface java.util.Iterator<E>remove in interface ParIterator<E>public void reset()
ParIteratorreset in interface ParIterator<E>public void globalBreak()
ParIteratorfalse is returned to every thread at the next call to
hasNext(). Therefore, all the threads safely stop iterating when they call hasNext() (includes
an implicit barrier to ensure all threads stop at the same time).globalBreak in interface ParIterator<E>ParIterator.localBreak()protected boolean allOtherThreadsHaveLocalBreaked(int tid)
public void register(java.lang.Exception e)
ParIteratorParIteratorException):
e - The exception that occurred
hasNext() method serves as the iteration boundary to determine the current element).
register in interface ParIterator<E>e - The exception to registerParIterator.getAllExceptions()public void register(java.lang.Exception e,
E currentElements)
public ParIteratorException<E>[] getAllExceptions()
ParIteratorgetAllExceptions in interface ParIterator<E>ParIteratorException), or an empty array if none were registered.ParIterator.register(Exception)public int getID()
ParIteratorgetID in interface ParIterator<E>