public class SerialDispatchQueue extends AbstractDispatchObject implements HawtDispatchQueue
DispatchQueue.QueueType| Modifier and Type | Field and Description |
|---|---|
private java.lang.ThreadLocal<java.lang.Boolean> |
executing |
protected java.util.concurrent.ConcurrentLinkedQueue<Task> |
externalQueue |
protected java.lang.String |
label |
private java.util.LinkedList<Task> |
localQueue |
private MetricsCollector |
metricsCollector |
private boolean |
profile |
private java.util.LinkedList<Task> |
sourceQueue |
protected java.util.concurrent.atomic.AtomicBoolean |
triggered |
targetQueuestartup, suspended| Constructor and Description |
|---|
SerialDispatchQueue(java.lang.String label) |
| Modifier and Type | Method and Description |
|---|---|
void |
assertExecuting()
Asserts that the current dispatch queue is executing.
|
private void |
checkCollector() |
DispatchQueue |
createQueue(java.lang.String label)
Creates a new serial dispatch queue with this queue set as it's
target queue.
|
private int |
drains() |
private void |
enqueue(Task runnable) |
void |
execute(java.lang.Runnable runnable)
Deprecated.
|
void |
execute(Task task)
Submits a task for asynchronous execution on a dispatch queue.
|
void |
executeAfter(long delay,
java.util.concurrent.TimeUnit unit,
java.lang.Runnable runnable)
Deprecated.
|
void |
executeAfter(long delay,
java.util.concurrent.TimeUnit unit,
Task task)
Schedule a task for execution on a given queue at a specified time.
|
HawtDispatcher |
getDispatcher() |
java.lang.String |
getLabel()
Returns the label of the queue.
|
DispatchQueue.QueueType |
getQueueType() |
java.util.LinkedList<Task> |
getSourceQueue() |
boolean |
isExecuting()
Returns true if this dispatch queue is executing the caller.
|
GlobalDispatchQueue |
isGlobalDispatchQueue() |
SerialDispatchQueue |
isSerialDispatchQueue() |
ThreadDispatchQueue |
isThreadDispatchQueue() |
Metrics |
metrics()
Returns the usage metrics of this queue.
|
protected void |
onResume() |
protected void |
onStartup() |
boolean |
profile() |
void |
profile(boolean profile)
Enables or disables profiler metric tracking on the queue.
|
void |
run() |
void |
setLabel(java.lang.String label)
Sets the label of the queue.
|
java.lang.String |
toString() |
protected void |
triggerExecution() |
getTargetQueue, setTargetQueueisSuspended, onSuspend, resume, suspendclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetTargetQueuesetTargetQueueisSuspended, resume, suspendprotected volatile java.lang.String label
protected final java.util.concurrent.atomic.AtomicBoolean triggered
protected final java.util.concurrent.ConcurrentLinkedQueue<Task> externalQueue
private final java.util.LinkedList<Task> localQueue
private final java.util.LinkedList<Task> sourceQueue
private final java.lang.ThreadLocal<java.lang.Boolean> executing
private MetricsCollector metricsCollector
private boolean profile
public void execute(Task task)
DispatchQueueSubmits a task for asynchronous execution on a dispatch queue.
DispatchQueue.execute(Task) is the fundamental mechanism for submitting
runnable objects to a dispatch queue.
Calls to DispatchQueue.execute(Task) always return immediately after the runnable has
been submitted, and never wait for the runnable to be executed.
The target queue determines whether the runnable will be invoked serially or concurrently with respect to other runnables submitted to that same queue. Serial queues are processed concurrently with with respect to each other.
execute in interface DispatchQueuetask - The task to submit to the dispatch queue.@Deprecated public void execute(java.lang.Runnable runnable)
DispatchQueueSubmits a runnable for asynchronous execution on a dispatch queue.
DispatchQueue.execute(Runnable) is the fundamental mechanism for submitting
runnable objects to a dispatch queue.
Calls to DispatchQueue.execute(Runnable) always return immediately after the runnable has
been submitted, and never wait for the runnable to be executed.
The target queue determines whether the runnable will be invoked serially or concurrently with respect to other runnables submitted to that same queue. Serial queues are processed concurrently with with respect to each other.
execute in interface java.util.concurrent.Executorexecute in interface DispatchQueuerunnable - The runnable to submit to the dispatch queue.@Deprecated
public void executeAfter(long delay,
java.util.concurrent.TimeUnit unit,
java.lang.Runnable runnable)
DispatchQueueSchedule a runnable for execution on a given queue at a specified time.
executeAfter in interface DispatchQueuedelay - the amount of time to delay before executing the runnableunit - the unit of time that the delay value is specified inpublic java.util.LinkedList<Task> getSourceQueue()
getSourceQueue in interface HawtDispatchQueueprivate void enqueue(Task runnable)
public void run()
run in interface java.lang.Runnablerun in class BaseSuspendableprotected void triggerExecution()
public java.lang.String getLabel()
DispatchQueueReturns the label of the queue.
getLabel in interface DispatchQueuepublic void setLabel(java.lang.String label)
DispatchQueueSets the label of the queue.
setLabel in interface DispatchQueuelabel - the label of the queue.public boolean isExecuting()
DispatchQueueReturns true if this dispatch queue is executing the caller.
isExecuting in interface DispatchQueuepublic void assertExecuting()
DispatchQueueassertExecuting in interface DispatchQueueprotected void onStartup()
onStartup in class BaseSuspendableprotected void onResume()
onResume in class BaseSuspendablepublic DispatchQueue.QueueType getQueueType()
getQueueType in interface DispatchQueuepublic void executeAfter(long delay,
java.util.concurrent.TimeUnit unit,
Task task)
DispatchQueueSchedule a task for execution on a given queue at a specified time.
executeAfter in interface DispatchQueuedelay - the amount of time to delay before executing the runnableunit - the unit of time that the delay value is specified inpublic DispatchQueue createQueue(java.lang.String label)
DispatchQueue
Creates a new serial dispatch queue with this queue set as it's
target queue. See Dispatch.createQueue(String) for
more information about serial dispatch queues.
createQueue in interface DispatchQueuelabel - the label to assign the dispatch queue, can be nullpublic HawtDispatcher getDispatcher()
getDispatcher in interface HawtDispatchQueuepublic SerialDispatchQueue isSerialDispatchQueue()
isSerialDispatchQueue in interface HawtDispatchQueuepublic ThreadDispatchQueue isThreadDispatchQueue()
isThreadDispatchQueue in interface HawtDispatchQueuepublic GlobalDispatchQueue isGlobalDispatchQueue()
isGlobalDispatchQueue in interface HawtDispatchQueuepublic void profile(boolean profile)
DispatchQueueprofile in interface DispatchQueuepublic boolean profile()
profile in interface DispatchQueueprivate void checkCollector()
public Metrics metrics()
DispatchQueuemetrics in interface DispatchQueueprivate int drains()
public java.lang.String toString()
toString in class java.lang.Object