org.fusesource.hawtdispatch
Interface DispatchQueue

All Superinterfaces:
DispatchObject, Executor, Suspendable

public interface DispatchQueue
extends DispatchObject, Executor

Dispatch queues are lightweight objects to which runnable objects may be submitted for asynchronous execution and therefore are Executor objects.

Author:
Hiram Chirino

Nested Class Summary
static class DispatchQueue.QueueType
          Defines the types of dispatch queues supported by the system.
 
Method Summary
 void assertExecuting()
          Asserts that the current dispatch queue is executing.
 DispatchQueue createQueue(String label)
           Creates a new serial dispatch queue with this queue set as it's target queue.
 void execute(Runnable runnable)
           Submits a runnable for asynchronous execution on a dispatch queue.
 void execute(Task task)
           Submits a task for asynchronous execution on a dispatch queue.
 void executeAfter(long delay, TimeUnit unit, Runnable runnable)
           Schedule a runnable for execution on a given queue at a specified time.
 void executeAfter(long delay, TimeUnit unit, Task task)
           Schedule a task for execution on a given queue at a specified time.
 String getLabel()
           Returns the label of the queue.
 DispatchQueue.QueueType getQueueType()
           
 boolean isExecuting()
           Returns true if this dispatch queue is executing the caller.
 Metrics metrics()
          Returns the usage metrics of this queue.
 void profile(boolean on)
          Enables or disables profiler metric tracking on the queue.
 void setLabel(String label)
           Sets the label of the queue.
 
Methods inherited from interface org.fusesource.hawtdispatch.DispatchObject
getTargetQueue, setTargetQueue
 
Methods inherited from interface org.fusesource.hawtdispatch.Suspendable
isSuspended, resume, suspend
 

Method Detail

getQueueType

DispatchQueue.QueueType getQueueType()
Returns:
the type of dispatch queue that this object implements.

createQueue

DispatchQueue createQueue(String label)

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.

Parameters:
label - the label to assign the dispatch queue, can be null
Returns:
the newly created dispatch queue

execute

void execute(Runnable runnable)

Submits a runnable for asynchronous execution on a dispatch queue.

execute(Runnable) is the fundamental mechanism for submitting runnable objects to a dispatch queue.

Calls to 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.

Specified by:
execute in interface Executor
Parameters:
runnable - The runnable to submit to the dispatch queue.

execute

void execute(Task task)

Submits a task for asynchronous execution on a dispatch queue.

execute(Task) is the fundamental mechanism for submitting runnable objects to a dispatch queue.

Calls to 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.

Parameters:
task - The task to submit to the dispatch queue.

executeAfter

void executeAfter(long delay,
                  TimeUnit unit,
                  Runnable runnable)

Schedule a runnable for execution on a given queue at a specified time.

Parameters:
delay - the amount of time to delay before executing the runnable
unit - the unit of time that the delay value is specified in
runnable -

executeAfter

void executeAfter(long delay,
                  TimeUnit unit,
                  Task task)

Schedule a task for execution on a given queue at a specified time.

Parameters:
delay - the amount of time to delay before executing the runnable
unit - the unit of time that the delay value is specified in
task -

getLabel

String getLabel()

Returns the label of the queue.

Returns:
the label of the queue. The result may be null.

setLabel

void setLabel(String label)

Sets the label of the queue.

Parameters:
label - the label of the queue.

isExecuting

boolean isExecuting()

Returns true if this dispatch queue is executing the caller.

Returns:
if this dispatch queue is executing the caller.

assertExecuting

void assertExecuting()
Asserts that the current dispatch queue is executing.


profile

void profile(boolean on)
Enables or disables profiler metric tracking on the queue.

Parameters:
on -

metrics

Metrics metrics()
Returns the usage metrics of this queue. Only returns a value if the queue has profiling enabled.

Returns:
new metric counters accumulated since last called or null if the queue has not been used.


Copyright © 2010-2014 FuseSource, Corp.. All Rights Reserved.