public class DFSonDAGBottomTop<V> extends ParIteratorAbstract<V>
ParIterator.Schedule
chunkSize, collection, data, exceptions, flags, ignoreBarrier, numOfThreads, reclaimedElements, threadID
DEFAULT_CHUNKSIZE
Constructor and Description |
---|
DFSonDAGBottomTop(GraphAdapterInterface tree,
V root2,
int numOfThreads) |
Modifier and Type | Method and Description |
---|---|
void |
forEachRemaining(java.util.function.Consumer<? super V> action) |
void |
globalBreak()
Causes all threads to stop processing elements at the next iteration boundary.
|
boolean |
hasNext()
This method returns TRUE if there is still available vertex in the
iterator (i.e.
|
boolean |
localBreak()
Attempts to excuse the current thread from continuing to iterate (and re-distribute all unprocessed elements to
the other threads).
|
V |
next()
Returns an element for the current thread to process.
|
allOtherThreadsHaveLocalBreaked, getAllExceptions, getID, register, register, remove, reset
public DFSonDAGBottomTop(GraphAdapterInterface tree, V root2, int numOfThreads)
public boolean hasNext()
true
if at least one element has been reserved for the calling thread (in which case it must follow up
with a call to next()
).
false
otherwise (in such a case, the calling thread blocks until all the other threads have completed
their iterations).ParIterator.next()
public V next()
ParIterator
hasNext()
(and received true
).
Note that calls to hasNext()
(that return true
) only allow for one corresponding and binding call to
hasNext()
. Therefore, multiple calls to hasNext()
have no effect until the corresponding
call to next()
takes place.
ParIterator.hasNext()
public void globalBreak()
ParIterator
false
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<V>
globalBreak
in class ParIteratorAbstract<V>
ParIterator.localBreak()
public boolean localBreak()
ParIterator
Therefore, (as opposed to globalBreak()
) this method guarantees that even if all threads attempt to
localBreak()
, at least one will fail and is left to traverse the remaining elements. Note that in many
cases, calling localBreak()
will break the original scheduling policy.
true
if the attempt is successful, false
otherwise.ParIterator.globalBreak()
public void forEachRemaining(java.util.function.Consumer<? super V> action)