public class BasicOperationQueue extends java.lang.Object implements IOperationQueue
IOperationQueue
offers a basic way to execute a bunch of
IOperation
s. The queue can be configured to execute the operations
serial (with one thread) or in parallel (multithreaded) by using
BasicOperationQueue(int)
IOperation
s are executed right after adding them with
addOperation(IOperation)
or addOperations(Vector)
. The
execution can be suspended and resumed with suspend()
and
resume()
.Constructor and Description |
---|
BasicOperationQueue()
Create a new queue.
|
BasicOperationQueue(boolean startRunner)
Create a new queue in suspended state.
|
BasicOperationQueue(int maxParallelOperations)
Create a new queue with maximum of parallel executions defined by the
given parameter.
|
BasicOperationQueue(int maxParallelOperations,
boolean startRunner)
Create a new queue with maximum of parallel executions defined by the
given parameter.
|
Modifier and Type | Method and Description |
---|---|
void |
addDelegate(IOperationDelegate delegate)
add a
IOperationDelegate that will be notified of events
happening with each IOperation s in the queue. |
void |
addDelegate(IOperationQueueDelegate queueDelegate)
add a
IOperationQueueDelegate that will be notified of events
happening with the queue, e.g. |
void |
addOperation(IOperation o)
add the given
IOperation to the queue |
void |
addOperations(java.util.Vector newOperations)
add a bunch of
IOperation s to the queue |
int |
getSize() |
boolean |
isIdle() |
void |
removeDelegate(IOperationDelegate delegate)
remove a
IOperationDelegate |
void |
removeDelegate(IOperationQueueDelegate queueDelegate)
remove a
IOperationQueueDelegate |
void |
reset()
reset the queue as if it were new, i.e.
|
void |
resume()
resume the execution of the operations in the queue; the implementation
should handle calling this method gracefully when already in running
|
void |
suspend()
halt the execution of the operations in the queue; the implementation
should handle calling this method gracefully when already in suspended
mode
|
public BasicOperationQueue()
public BasicOperationQueue(int maxParallelOperations)
maxParallelOperations
- the number of parallel executionspublic BasicOperationQueue(boolean startRunner)
resume()
to start the
execution.startRunner
- if true
, the queue will start immediately,
otherwise it will be suspended until explicitly resumed with
resume()
public BasicOperationQueue(int maxParallelOperations, boolean startRunner)
maxParallelOperations
- the number of parallel executions; must be a positive numberstartRunner
- if true
, the queue will start immediately,
otherwise it will be suspended until explicitly resumed with
resume()
public void reset()
IOperationQueue
reset
in interface IOperationQueue
public void suspend()
IOperationQueue
suspend
in interface IOperationQueue
public void resume()
IOperationQueue
resume
in interface IOperationQueue
public boolean isIdle()
isIdle
in interface IOperationQueue
true
if there are no operations in the queue and no
operations are currently executed; false
otherwisepublic void addOperation(IOperation o)
IOperationQueue
IOperation
to the queueaddOperation
in interface IOperationQueue
o
- the IOperation
to be addedpublic void addOperations(java.util.Vector newOperations)
IOperationQueue
IOperation
s to the queueaddOperations
in interface IOperationQueue
newOperations
- the IOperation
s to be addedpublic int getSize()
getSize
in interface IOperationQueue
public void addDelegate(IOperationDelegate delegate)
IOperationQueue
IOperationDelegate
that will be notified of events
happening with each IOperation
s in the queue. If the same
IOperationDelegate
is already added, it will not be added again.addDelegate
in interface IOperationQueue
delegate
- the IOperationDelegate
to be addedpublic void removeDelegate(IOperationDelegate delegate)
IOperationQueue
IOperationDelegate
removeDelegate
in interface IOperationQueue
delegate
- the IOperationDelegate
to be removedpublic void addDelegate(IOperationQueueDelegate queueDelegate)
IOperationQueue
IOperationQueueDelegate
that will be notified of events
happening with the queue, e.g. when the queue is finished. If the same
IOperationQueueDelegate
is already added, it will not be added
again.addDelegate
in interface IOperationQueue
public void removeDelegate(IOperationQueueDelegate queueDelegate)
IOperationQueue
IOperationQueueDelegate
removeDelegate
in interface IOperationQueue
queueDelegate
- the IOperationQueueDelegate
to be removed