org.apache.pivot.util.concurrent
Class TaskGroup

java.lang.Object
  extended by org.apache.pivot.util.concurrent.Task<Void>
      extended by org.apache.pivot.util.concurrent.TaskGroup
All Implemented Interfaces:
Iterable<Task<?>>, Group<Task<?>>

public class TaskGroup
extends Task<Void>
implements Group<Task<?>>, Iterable<Task<?>>

Task that runs a group of tasks in parallel and notifies listeners when all tasks are complete.


Field Summary
 
Fields inherited from class org.apache.pivot.util.concurrent.Task
abort, DEFAULT_EXECUTOR_SERVICE, timeout
 
Constructor Summary
TaskGroup()
           
TaskGroup(ExecutorService executorService)
           
 
Method Summary
 void abort()
          Aborts all tasks in this group.
 boolean add(Task<?> element)
          Adds an element to the group.
 boolean contains(Task<?> element)
          Tests the existence of an element in the group.
 Void execute()
          Synchronously executes the task.
 int getCount()
           
 Iterator<Task<?>> iterator()
           
 boolean remove(Task<?> element)
          Removes an element from the group.
 
Methods inherited from class org.apache.pivot.util.concurrent.Task
execute, execute, getExecutorService, getFault, getResult, getTimeout, isPending, setTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TaskGroup

public TaskGroup()

TaskGroup

public TaskGroup(ExecutorService executorService)
Method Detail

execute

public Void execute()
             throws TaskExecutionException
Description copied from class: Task
Synchronously executes the task.

Specified by:
execute in class Task<Void>
Returns:
The result of the task's execution.
Throws:
TaskExecutionException - If an error occurs while executing the task.

abort

public void abort()
Aborts all tasks in this group.

Overrides:
abort in class Task<Void>

add

public boolean add(Task<?> element)
Description copied from interface: Group
Adds an element to the group.

Specified by:
add in interface Group<Task<?>>
Parameters:
element - The element to add to the group.
Returns:
true if the element was added to the group; false, otherwise.

remove

public boolean remove(Task<?> element)
Description copied from interface: Group
Removes an element from the group.

Specified by:
remove in interface Group<Task<?>>
Parameters:
element - The element to remove from the set.
Returns:
true if the element was removed from the group; false, otherwise.

contains

public boolean contains(Task<?> element)
Description copied from interface: Group
Tests the existence of an element in the group.

Specified by:
contains in interface Group<Task<?>>
Parameters:
element - The element whose presence in the group is to be tested.
Returns:
true if the element exists in the group; false, otherwise.

getCount

public int getCount()

iterator

public Iterator<Task<?>> iterator()
Specified by:
iterator in interface Iterable<Task<?>>