public final class ThreadDispatchQueue extends java.lang.Object implements HawtDispatchQueue
DispatchQueue.QueueType| Modifier and Type | Field and Description |
|---|---|
(package private) GlobalDispatchQueue |
globalQueue |
(package private) java.lang.String |
label |
(package private) java.util.LinkedList<Task> |
localTasks |
(package private) java.util.concurrent.ConcurrentLinkedQueue<Task> |
sharedTasks |
private java.util.LinkedList<Task> |
sourceQueue |
(package private) WorkerThread |
thread |
| Constructor and Description |
|---|
ThreadDispatchQueue(GlobalDispatchQueue globalQueue,
WorkerThread thread) |
| Modifier and Type | Method and Description |
|---|---|
void |
assertExecuting()
Asserts that the current dispatch queue is executing.
|
DispatchQueue |
createQueue(java.lang.String label)
Creates a new serial dispatch queue with this queue set as it's
target queue.
|
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.
|
DispatchPriority |
getPriority() |
DispatchQueue.QueueType |
getQueueType() |
java.util.LinkedList<Task> |
getSourceQueue() |
HawtDispatchQueue |
getTargetQueue()
Gets the target queue for this object.
|
WorkerThread |
getThread() |
boolean |
isExecuting()
Returns true if this dispatch queue is executing the caller.
|
GlobalDispatchQueue |
isGlobalDispatchQueue() |
SerialDispatchQueue |
isSerialDispatchQueue() |
boolean |
isSuspended() |
ThreadDispatchQueue |
isThreadDispatchQueue() |
Metrics |
metrics()
Returns the usage metrics of this queue.
|
Task |
poll() |
boolean |
profile() |
void |
profile(boolean on)
Enables or disables profiler metric tracking on the queue.
|
void |
resume()
Resumes the invocation of tasks on a dispatch object.
|
void |
setLabel(java.lang.String label)
Sets the label of the queue.
|
void |
setTargetQueue(DispatchQueue queue)
Sets the target queue for this object.
|
void |
suspend()
Suspends the invocation of tasks on a dispatch object.
|
volatile java.lang.String label
final java.util.LinkedList<Task> localTasks
final java.util.concurrent.ConcurrentLinkedQueue<Task> sharedTasks
final WorkerThread thread
final GlobalDispatchQueue globalQueue
private final java.util.LinkedList<Task> sourceQueue
public ThreadDispatchQueue(GlobalDispatchQueue globalQueue, WorkerThread thread)
public java.util.LinkedList<Task> getSourceQueue()
getSourceQueue in interface HawtDispatchQueuepublic 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 DispatchQueuepublic HawtDispatcher getDispatcher()
getDispatcher in interface HawtDispatchQueue@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 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.public Task poll()
public 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 void resume()
SuspendableResumes the invocation of tasks on a dispatch object.
resume in interface SuspendableSuspendable.suspend()public void suspend()
SuspendableSuspends the invocation of tasks on a dispatch object.
A suspended object will not invoke any tasks associated with it. The suspension of an object will occur after any running runnable associated with the object completes.
Calls to Suspendable.suspend() must be balanced with calls
to Suspendable.resume().
suspend in interface SuspendableSuspendable.resume()public boolean isSuspended()
isSuspended in interface SuspendableSuspendable.resume(),
Suspendable.suspend()public void setTargetQueue(DispatchQueue queue)
DispatchObjectSets the target queue for this object.
An object's target queue is responsible for processing the object.
A dispatch queue's priority is inherited by its target queue. Use the
Dispatch.getGlobalQueue() method to obtain suitable target queue
of the desired priority.
A dispatch source's target queue specifies where its event handler and cancellation handler runnables will be submitted.
setTargetQueue in interface DispatchObjectqueue - The new target queue for the object. The queue is retained, and the
previous one, if any, is released.
The result of passing NULL in this parameter is undefined.public HawtDispatchQueue getTargetQueue()
DispatchObjectGets the target queue for this object.
getTargetQueue in interface DispatchObjectgetTargetQueue in interface HawtDispatchQueueDispatchObject.setTargetQueue(DispatchQueue)public DispatchPriority getPriority()
public GlobalDispatchQueue isGlobalDispatchQueue()
isGlobalDispatchQueue in interface HawtDispatchQueuepublic SerialDispatchQueue isSerialDispatchQueue()
isSerialDispatchQueue in interface HawtDispatchQueuepublic ThreadDispatchQueue isThreadDispatchQueue()
isThreadDispatchQueue in interface HawtDispatchQueuepublic 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 DispatchQueue.QueueType getQueueType()
getQueueType in interface DispatchQueuepublic void profile(boolean on)
DispatchQueueprofile in interface DispatchQueuepublic boolean profile()
profile in interface DispatchQueuepublic Metrics metrics()
DispatchQueuemetrics in interface DispatchQueuepublic WorkerThread getThread()