galois.runtime.wl
Interface Worklist<T>

Type Parameters:
T - type of elements contained in the worklist
All Known Subinterfaces:
OrderableWorklist<T>
All Known Implementing Classes:
BoundedFIFO, BoundedLIFO, Bucketed, BulkSynchronous, BulkSynchronousLeaf, ChunkedFIFO, ChunkedLIFO, ChunkedRandomOrder, FIFO, LIFO, Ordered, RandomOrder, RandomPermutation

public interface Worklist<T>

Worklist used by Galois iterators. Worklists are not intended to be instantiated directly but rather by passing an ordering rule to the iterator.

See Also:
Priority.Rule, GaloisRuntime.foreach(Iterable, util.fn.Lambda2Void, galois.runtime.wl.Priority.Rule)

Method Summary
 void add(T item, ForeachContext<T> ctx)
          Adds an element to this worklist.
 void addInitial(T item, ForeachContext<T> ctx)
          Adds an element to this worklist.
 void finishAddInitial()
          Marks when no more elements will be added from the initial elements passed to an executor.
 boolean isEmpty()
          Checks for emptiness.
 Worklist<T> newInstance()
           
 T poll(ForeachContext<T> ctx)
          Removes an element from this worklist.
 int size()
           
 

Method Detail

addInitial

void addInitial(T item,
                ForeachContext<T> ctx)
Adds an element to this worklist. This method is used when adding elements from the initial elements passed to an executor. Thread-safe.

Parameters:
item - the item to add
ctx - an executor context

finishAddInitial

void finishAddInitial()
Marks when no more elements will be added from the initial elements passed to an executor.


add

void add(T item,
         ForeachContext<T> ctx)
Adds an element to this worklist. This method is used for newly generated elements or elements added during Galois execution. Thread-safe.

Parameters:
item - the item to add
ctx - an executor context

poll

T poll(ForeachContext<T> ctx)
Removes an element from this worklist. Thread-safe.

Parameters:
ctx - an executor context
Returns:
an element or null if there are no more elements in this worklist

isEmpty

boolean isEmpty()
Checks for emptiness. Only called by one thread at a time so does not have to be thread-safe. Also, can assume that all threads have had poll(ForeachContext) return null.

Returns:
true if there are no more elements in this worklist

size

int size()
Returns:
the number of elements in this worklist, during concurrent execution this may be a lower bound on the number of elements

newInstance

Worklist<T> newInstance()
Returns:
a new, empty instance of this worklist