|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mmtk.utility.deque.Deque org.mmtk.utility.deque.SharedDeque
public class SharedDeque
This supports unsynchronized enqueuing and dequeuing of buffers for shared use. The data can be added to and removed from either end of the deque.
Field Summary | |
---|---|
private int |
arity
Number of words per entry |
private int |
bufsenqueued
|
private int |
completionFlag
Completion flag - set when all consumers have arrived at the barrier |
private static boolean |
DISABLE_WAITING
|
protected Address |
head
Head of the shared deque |
private Lock |
lock
|
private String |
name
The name of this shared deque - for diagnostics |
private static Offset |
NEXT_OFFSET
|
private int |
numConsumers
# active threads - processing is complete when # waiting == this |
private int |
numConsumersWaiting
# threads waiting |
private static Offset |
PREV_OFFSET
|
private RawPageSpace |
rps
Raw page space from which to allocate |
protected Address |
tail
Tail of the shared deque |
private static long |
TIMEOUT_PERIOD
|
private static boolean |
TRACE
|
private static boolean |
TRACE_BLOCKERS
|
private static boolean |
TRACE_DETAIL
|
private static long |
WARN_PERIOD
|
Fields inherited from class org.mmtk.utility.deque.Deque |
---|
BUFFER_MASK, BUFFER_SIZE, HEAD_INITIAL_VALUE, LOG_PAGES_PER_BUFFER, META_DATA_SIZE, NEXT_FIELD_OFFSET, PAGES_PER_BUFFER, TAIL_INITIAL_VALUE, USABLE_BUFFER_BYTES |
Constructor Summary | |
---|---|
SharedDeque(String name,
RawPageSpace rps,
int arity)
Constructor |
Method Summary | |
---|---|
(package private) Address |
alloc()
|
void |
assertExhausted()
|
private boolean |
checkDequeLength(int length)
Check the number of buffers in the work queue (for debugging purposes). |
private void |
clearCompletionFlag()
Clear the completion flag. |
void |
clearDeque(int arity)
|
private boolean |
complete()
Is the current round of processing complete ? |
private Address |
dequeue(boolean waiting,
boolean fromTail)
Dequeue a block from the shared pool. |
(package private) Address |
dequeue(int arity)
|
(package private) Address |
dequeue(int arity,
boolean fromTail)
|
(package private) Address |
dequeueAndWait(int arity)
|
(package private) Address |
dequeueAndWait(int arity,
boolean fromTail)
|
(package private) void |
enqueue(Address buf,
int arity,
boolean toTail)
Enqueue a block on the head or tail of the shared queue |
int |
enqueuedPages()
|
(package private) void |
free(Address buf)
|
(package private) int |
getArity()
Get the arity (words per entry) of this queue |
protected Address |
getNext(Address buf)
Get the "next" pointer in a buffer forming the linked buffer chain. |
protected Address |
getPrev(Address buf)
Get the "next" pointer in a buffer forming the linked buffer chain. |
private void |
lock()
Lock this shared queue. |
void |
prepare()
Prepare for parallel processing. |
private void |
prepare(int consumers)
Prepare for parallel processing where a specific number of threads take part. |
void |
prepareNonBlocking()
Prepare for processing where pop operations on the deques will never block. |
void |
reset()
|
private void |
setCompletionFlag()
Set the completion flag. |
private void |
setHead(Address newHead)
|
private static void |
setNext(Address buf,
Address next)
Set the "next" pointer in a buffer forming the linked buffer chain. |
private void |
setNumConsumers(int newNumConsumers)
|
private void |
setNumConsumersWaiting(int newNCW)
|
private void |
setPrev(Address buf,
Address prev)
Set the "prev" pointer in a buffer forming the linked buffer chain. |
private void |
setTail(Address newTail)
|
private void |
spinWait(boolean fromTail)
Spinwait for GC work to arrive |
private void |
unlock()
Release the lock. |
Methods inherited from class org.mmtk.utility.deque.Deque |
---|
bufferEnd, bufferFirst, bufferLast, bufferLast, bufferLastOffset, bufferOffset, bufferStart |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final boolean DISABLE_WAITING
private static final Offset NEXT_OFFSET
private static final Offset PREV_OFFSET
private static final boolean TRACE
private static final boolean TRACE_DETAIL
private static final boolean TRACE_BLOCKERS
private final String name
private RawPageSpace rps
private final int arity
private volatile int completionFlag
private volatile int numConsumers
private volatile int numConsumersWaiting
protected volatile Address head
protected volatile Address tail
private volatile int bufsenqueued
private Lock lock
private static final long WARN_PERIOD
private static final long TIMEOUT_PERIOD
Constructor Detail |
---|
public SharedDeque(String name, RawPageSpace rps, int arity)
Method Detail |
---|
final int getArity()
final void enqueue(Address buf, int arity, boolean toTail)
buf
- arity
- toTail
- public final void clearDeque(int arity)
final Address dequeue(int arity)
final Address dequeue(int arity, boolean fromTail)
final Address dequeueAndWait(int arity)
final Address dequeueAndWait(int arity, boolean fromTail)
public final void prepare()
public final void prepareNonBlocking()
private void prepare(int consumers)
consumers
- # threads taking part.public final void reset()
public final void assertExhausted()
final Address alloc()
final void free(Address buf)
public final int enqueuedPages()
private Address dequeue(boolean waiting, boolean fromTail)
waiting
- fromTail
-
private void spinWait(boolean fromTail)
fromTail
- Check the head or the tail ?private static void setNext(Address buf, Address next)
buf
- The buffer whose next field is to be set.next
- The reference to which next should point.protected final Address getNext(Address buf)
buf
- The buffer whose next field is to be returned.
private void setPrev(Address buf, Address prev)
buf
- The buffer whose next field is to be set.prev
- The reference to which prev should point.protected final Address getPrev(Address buf)
buf
- The buffer whose next field is to be returned.
private boolean checkDequeLength(int length)
length
- The number of buffers believed to be in the queue.
private void lock()
private void unlock()
private boolean complete()
private void setCompletionFlag()
private void clearCompletionFlag()
private void setNumConsumers(int newNumConsumers)
private void setNumConsumersWaiting(int newNCW)
private void setHead(Address newHead)
private void setTail(Address newTail)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |