@InterfaceAudience.Private public abstract class AbstractProcedureScheduler extends Object implements ProcedureScheduler
| Constructor and Description |
|---|
AbstractProcedureScheduler() |
| Modifier and Type | Method and Description |
|---|---|
void |
addBack(Procedure procedure)
Inserts the specified element at the end of this queue.
|
void |
addFront(Procedure procedure)
Inserts the specified element at the front of this queue.
|
protected abstract Procedure |
dequeue()
Fetch one Procedure from the queue
NOTE: this method is called with the sched lock held.
|
protected abstract void |
enqueue(Procedure procedure,
boolean addFront)
Add the procedure to the queue.
|
long |
getNullPollCalls() |
long |
getPollCalls() |
boolean |
hasRunnables() |
Procedure |
poll()
Fetch one Procedure from the queue
|
Procedure |
poll(long nanos) |
Procedure |
poll(long timeout,
TimeUnit unit)
Fetch one Procedure from the queue
|
protected void |
push(Procedure procedure,
boolean addFront,
boolean notify) |
protected abstract boolean |
queueHasRunnables()
Returns true if there are procedures available to process.
|
protected abstract int |
queueSize()
Returns the number of elements in this queue.
|
protected void |
schedLock() |
protected void |
schedUnlock() |
void |
signalAll()
In case the class is blocking on poll() waiting for items to be added,
this method should awake poll() and poll() should return.
|
int |
size()
Returns the number of elements in this queue.
|
void |
start()
Start the scheduler
|
void |
stop()
Stop the scheduler
|
void |
suspendEvent(ProcedureEvent event)
Mark the event as not ready.
|
boolean |
waitEvent(ProcedureEvent event,
Procedure procedure)
Suspend the procedure if the event is not ready yet.
|
protected void |
waitProcedure(ProcedureDeque waitQueue,
Procedure proc) |
void |
wakeEvent(ProcedureEvent event)
Wake every procedure waiting for the specified event
(By design each event has only one "wake" caller)
|
void |
wakeEvents(int count,
ProcedureEvent... events)
Wake every procedure waiting for the specified events.
|
protected void |
wakePollIfNeeded(int waitingCount) |
protected void |
wakeProcedure(Procedure procedure) |
protected int |
wakeWaitingProcedures(ProcedureDeque waitQueue)
Wakes up given waiting procedures by pushing them back into scheduler queues.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclear, completionCleanup, getLockResource, getLocks, yieldpublic void start()
ProcedureSchedulerstart in interface ProcedureSchedulerpublic void stop()
ProcedureSchedulerstop in interface ProcedureSchedulerpublic void signalAll()
ProcedureSchedulersignalAll in interface ProcedureSchedulerprotected abstract void enqueue(Procedure procedure, boolean addFront)
procedure - the Procedure to addaddFront - true if the item should be added to the front of the queuepublic void addFront(Procedure procedure)
ProcedureScheduleraddFront in interface ProcedureSchedulerprocedure - the Procedure to addpublic void addBack(Procedure procedure)
ProcedureScheduleraddBack in interface ProcedureSchedulerprocedure - the Procedure to addprotected void push(Procedure procedure, boolean addFront, boolean notify)
protected abstract Procedure dequeue()
public Procedure poll()
ProcedureSchedulerpoll in interface ProcedureSchedulerpublic Procedure poll(long timeout, TimeUnit unit)
ProcedureSchedulerpoll in interface ProcedureSchedulertimeout - how long to wait before giving up, in units of unitunit - a TimeUnit determining how to interpret the timeout parameterpublic Procedure poll(long nanos)
protected abstract int queueSize()
protected abstract boolean queueHasRunnables()
public int size()
ProcedureSchedulersize in interface ProcedureSchedulerpublic boolean hasRunnables()
hasRunnables in interface ProcedureSchedulerpublic long getPollCalls()
public long getNullPollCalls()
public boolean waitEvent(ProcedureEvent event, Procedure procedure)
ProcedureSchedulerwaitEvent in interface ProcedureSchedulerevent - the event to wait onprocedure - the procedure waiting on the eventpublic void suspendEvent(ProcedureEvent event)
ProcedureSchedulersuspendEvent in interface ProcedureSchedulerevent - the event to mark as suspended/not readypublic void wakeEvent(ProcedureEvent event)
ProcedureSchedulerwakeEvent in interface ProcedureSchedulerevent - the event to waitpublic void wakeEvents(int count,
ProcedureEvent... events)
ProcedureSchedulerwakeEvents in interface ProcedureSchedulercount - the number of events in the array to wakeevents - the list of events to wakeprotected int wakeWaitingProcedures(ProcedureDeque waitQueue)
waitQueue.protected void waitProcedure(ProcedureDeque waitQueue, Procedure proc)
protected void wakeProcedure(Procedure procedure)
protected void schedLock()
protected void schedUnlock()
protected void wakePollIfNeeded(int waitingCount)
Copyright © 2007–2017 The Apache Software Foundation. All rights reserved.