SUMMARY:  INNER | FIELD | CONSTR | METHOD | FRIEND DETAIL:  FIELD | CONSTR | METHOD | FRIEND


Platform::Thread
Class TaskGroup

NonCopyableType
   |
   +-TaskGroup

Implemented in:
Platform.Thread.TaskGroup.h

class TaskGroup:
private NonCopyableType

A task group represents a set of tasks, each running in its own execution thread.

See Also:
Thread::Task, Thread::IRunnable

Constructor Summarycollapse
TaskGroup(IRunnable* runnable, Int count, ExceptionHandler* ehandler = Null)
          Creates a task group which runs a given runnable object in the specified number of execution threads.
TaskGroup(IRunnable* runnable[], Int count, ExceptionHandler* ehandler = Null)
          Creates a task group which runs the specified set of runnable objects, each in its own execution thread.
~TaskGroup()
          Destroys this task group.

Method Summarycollapse
Void cancel()
          Sends a cancel signal to all the tasks in this group.
Void interrupt(Int code = 0)
          Sends an interrupt with the specified value to all the tasks in this group.
Int join(Int milliseconds = 0)
          Waits until all the tasks in the group have completed execution.
Task& operator[](Int index)
          Retrieves a reference to a task object at the given index.
const Task& operator[](Int index) const
          Retrieves a reference to a task object at the given index.
Void priority(Priority priority) const
          Sets the relative priority for all the tasks in this group.
Int size() const
          Returns the total number of runnable tasks in this group.
String toString() const
          Returns a string representation of this task group.

 

Constructor Detail

TaskGroup[inline]

TaskGroup(IRunnable* runnable, Int count, ExceptionHandler* ehandler = Null)

Creates a task group which runs a given runnable object in the specified number of execution threads.

Parameters:
runnable - a runnable object to run in this task group
count - the number of tasks (execution threads) to create for the runnable object
ehandler - top level exception handler, if Null a default handler is provided by the platform
Remarks:
if an exception is thrown during creation of a task group the operation is rolled back such that the already created tasks are canceled and destroyed, and the exception is then rethrown
Throws:
TaskCreateException
See Also:
Thread::IRunnable

TaskGroup[inline]

TaskGroup(IRunnable* runnable[], Int count, ExceptionHandler* ehandler = Null)

Creates a task group which runs the specified set of runnable objects, each in its own execution thread.

Parameters:
runnable - a set of runnable objects to run in this task group
count - the number of runnable objects in the set
ehandler - top level exception handler, if Null a default handler is provided by the platform
Remarks:
if an exception is thrown during creation of a task group the operation is rolled back such that the already created tasks are canceled and destroyed, and the exception is then rethrown
Throws:
TaskCreateException
See Also:
Thread::IRunnable

~TaskGroup[nothrow, inline]

~TaskGroup()

Destroys this task group.

 

Method Detail

cancel[nothrow, inline]

Void cancel()

Sends a cancel signal to all the tasks in this group.

See Also:
Thread::CancelSignal, Thread::isCanceled

interrupt[nothrow, inline]

Void interrupt(Int code = 0)

Sends an interrupt with the specified value to all the tasks in this group.

Parameters:
code - an interrupt code
See Also:
Thread::InterruptSignal, Thread::isInterrupted

join[inline]

Int join(Int milliseconds = 0)

Waits until all the tasks in the group have completed execution. This is a blocking method. If the timeout parameter is zero (no timeout) this method will block the calling thread until the state of all the tasks in the group have become Thread::State_Completed. If the timeout parameter is greater than zero this method will wait for each of the tasks to complete within the specified amount of time and then return regardless of tasks' state.

This method is an interruption- and cancellation point. If any of the tasks within the group receive an interrupt or cancel signals, this method will unblock the calling thread and throw an exception: either Thread::CancelSignal or Thread::InterruptSignal respectively.

Parameters:
milliseconds - the time to wait for each of the tasks to complete, in milliseconds
Returns:
the number of tasks in the group that were joined; note that this value may be lower than the total number of tasks in the group because some of the threads may already have completed execution prior to the join call
Throws:
Thread::InterruptSignal
Thread::CancelSignal
See Also:
Thread::Task::join, Thread::State, Thread::isInterrupted, Thread::isCanceled

operator[][inline]

Task& operator[](Int index)

Retrieves a reference to a task object at the given index.

Parameters:
index - an index
Returns:
a reference to a task object
See Also:
Thread::Task

operator[][inline]

const Task& operator[](Int index) const

Retrieves a reference to a task object at the given index.

Parameters:
index - an index
Returns:
a reference to a task object
See Also:
Thread::Task

priority[nothrow, inline]

Void priority(Priority priority) const

Sets the relative priority for all the tasks in this group.

Parameters:
priority - a priority
See Also:
Thread::Priority, Thread::priority, Task::priority

size[inline]

Int size() const

Returns the total number of runnable tasks in this group.

Returns:
the number of runnable tasks in this group

toString[nothrow]

String toString() const

Returns a string representation of this task group.

Returns:
a string representation of this task group
See Also:
Task::toString


SUMMARY:  INNER | FIELD | CONSTR | METHOD | FRIEND DETAIL:  FIELD | CONSTR | METHOD | FRIEND