|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectpt.queues.WorkStealingQueue<E>
pt.queues.FifoLifoQueue<E>
E - The type of elements held in this collectionpublic class FifoLifoQueue<E>
A mixed-schedule queue. Elements may be added using either a FIFO policy (addGlobal(Object)),
or a LIFO policy (addLocal(Object)).
If only addLocal(Object) is used, then this collection will essentially behave like a WorkStealingQueue.
If only addGlobal(Object) is used, then this collection will essentially behave like a standard FIFO queue.
Having the ability to add both locally and globally allows for increased flexibility. For example, ParaTask uses this
queue to ensure fairness for non-recursive tasks, while also ensuring that recursive tasks are handled.
The "head of queue" in the context of a FifoLifoQueue refers to the element according to this schedule. There are three
possibilities where the "head of queue" element might come from. First, an
element is attempted to be taken from the thread's local queue. If this fails, then an element is removed from the
shared global queue. If this fails, an element is stolen from another thread's local queue.
| Field Summary |
|---|
| Fields inherited from class pt.queues.WorkStealingQueue |
|---|
capacity, chunksize, HALF, localDeques, remainingCapacity, sleep_amount_milli |
| Constructor Summary | |
|---|---|
FifoLifoQueue()
Creates an empty queue with maximum capacity and chunksize of 1. |
|
FifoLifoQueue(java.util.Collection<? extends E> c,
int chunksize)
Creates a queue containing the specified collection with the specified chunksize. |
|
FifoLifoQueue(int capacity,
int chunksize)
Creates an empty queue with the specified chunksize and capacity. |
|
FifoLifoQueue(long[] threadPoolIDs)
Create an empty queue with unlimited capacity and chunksize of 1. |
|
| Method Summary | |
|---|---|
boolean |
add(E e)
Deprecated. If the calling thread already has a local queue, or the calling thread is registered as a worker thread, then this call is equivalent to addLocal(Object). Otherwise,
the call is equivalent to addGlobal(Object). It is therefore recommended to explicitly use
addLocal(Object) or addGlobal(Object) to ensure the correct intention is performed. |
boolean |
addGlobal(E e)
Add the specified element globally. |
boolean |
addLocal(E e)
Add the specified element locally. |
protected java.util.ArrayList<E> |
asList()
|
void |
clear()
|
boolean |
contains(java.lang.Object o)
|
int |
drainTo(java.util.Collection<? super E> c,
int maxElements)
|
E |
element()
|
boolean |
isEmpty()
|
E |
poll()
|
boolean |
remove(java.lang.Object o)
|
void |
setThreadPoolIDs(long[] threadPoolIDs)
Set the set of threads that will be the worker-threads. |
int |
size()
|
| Methods inherited from class pt.queues.WorkStealingQueue |
|---|
addAll, attemptToStealNonRandom, attemptToStealRandom, containsAll, drainTo, iterator, offer, offer, peek, poll, pollLocalQueue, put, remainingCapacity, remove, removeAll, retainAll, take, toArray, toArray |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Collection |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public FifoLifoQueue()
public FifoLifoQueue(int capacity,
int chunksize)
capacity - chunksize -
public FifoLifoQueue(java.util.Collection<? extends E> c,
int chunksize)
c - chunksize - public FifoLifoQueue(long[] threadPoolIDs)
threadPoolIDs - setThreadPoolIDs(long[])| Method Detail |
|---|
public void setThreadPoolIDs(long[] threadPoolIDs)
threadPoolIDs - public boolean addLocal(E e)
e - the element to add
true (as specified by Collection.add(E))public boolean addGlobal(E e)
e - the element to add
true (as specified by Collection.add(E))public boolean add(E e)
addLocal(Object). Otherwise,
the call is equivalent to addGlobal(Object). It is therefore recommended to explicitly use
addLocal(Object) or addGlobal(Object) to ensure the correct intention is performed.
add in interface java.util.Collection<E>add in interface java.util.concurrent.BlockingQueue<E>add in interface java.util.Queue<E>add in class WorkStealingQueue<E>public boolean contains(java.lang.Object o)
contains in interface java.util.Collection<E>contains in interface java.util.concurrent.BlockingQueue<E>contains in class WorkStealingQueue<E>
public int drainTo(java.util.Collection<? super E> c,
int maxElements)
drainTo in interface java.util.concurrent.BlockingQueue<E>drainTo in class WorkStealingQueue<E>public boolean remove(java.lang.Object o)
remove in interface java.util.Collection<E>remove in interface java.util.concurrent.BlockingQueue<E>remove in class WorkStealingQueue<E>public E element()
element in interface java.util.Queue<E>element in class WorkStealingQueue<E>public E poll()
poll in interface java.util.Queue<E>poll in class WorkStealingQueue<E>public void clear()
clear in interface java.util.Collection<E>clear in class WorkStealingQueue<E>public boolean isEmpty()
isEmpty in interface java.util.Collection<E>isEmpty in class WorkStealingQueue<E>public int size()
size in interface java.util.Collection<E>size in class WorkStealingQueue<E>protected java.util.ArrayList<E> asList()
asList in class WorkStealingQueue<E>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||