# saga::task_container Class Reference

Handles a large number of asynchronous operations. More...

`#include <task_container.hpp>`

Inheritance diagram for saga::task_container:

[legend]

List of all members.

## Public Types
enum | wait_mode { All = 1, Any = 2 }
| The wait mode enum specifies the condition on which a wait() operation on a saga::task container returns. More...
## Public Member Functions
| task_container (void)
| Creates a task_container.
| ~task_container (void)
| Destroys a task_container.
void | run ()
| Start all asynchronous operations in the container.
void | add_task (task t)
| Adds a task to a task_container.
void | remove_task (task t)
| Removes a task from a task_container.
std::vector< task > | list_tasks (void) const
| Lists the tasks in the task_container.
std::vector< task_base::state > | get_states (void) const
| Gets the states of all tasks in the task_container.
void | cancel (void)
| Cancels all the asynchronous operations in the container.
std::vector< task > | wait (wait_mode mode=All, float timeout=-1.0)
| Wait for one or more of the tasks to finish.

## Detailed Description

Handles a large number of asynchronous operations.

Managing a large number of tasks can be tedious. The task_container class is designed to help in these situations, and to effectively handle a large number of asynchronous operations.

## Member Enumeration Documentation

enum saga::task_container::wait_mode

The wait mode enum specifies the condition on which a wait() operation on a saga::task container returns.

Enumerator:

  All | wait() returns if all tasks in the container reached a final state
  Any | wait() returns if one or more tasks in the container reached a final state.

## Constructor & Destructor Documentation

saga::task_container::task_container | ( | void |  | ) |

Creates a task_container.

saga::task_container::~task_container | ( | void |  | ) |

Destroys a task_container.

## Member Function Documentation

void saga::task_container::run | ( | void |  | ) |

Start all asynchronous operations in the container.

void saga::task_container::add_task | ( | task | t | ) |

Adds a task to a task_container.

Parameters:

  | task | Task to add to the task_container.

Returns:
  Cookie identifying the added task.

void saga::task_container::remove_task | ( | task | t | ) |

Removes a task from a task_container.

Parameters:

  | task | Cookie identifying the task to be removed.

Returns:
  The removed task.

std::vector< task > saga::task_container::list_tasks | ( | void |  | ) | const

Lists the tasks in the task_container.

Returns:
  Array of cookies for all tasks in task_container.

std::vector< task_base::state > saga::task_container::get_states | ( | void |  | ) | const

Gets the states of all tasks in the task_container.

Returns:
  Array of states for tasks in task_container.

void saga::task_container::cancel | ( | void |  | ) |

Cancels all the asynchronous operations in the container.

Parameters:

  | timeout | Time for freeing resources.

std::vector< task > saga::task_container::wait | ( | wait_mode | mode = `All`,
|  | float | timeout = `-1.0` |
| ) |  |  |

Wait for one or more of the tasks to finish.

Parameters:

  | mode | Wait for all or any task
  | timeout | Seconds to wait

Returns:
  Finished task

The documentation for this class was generated from the following files:

- task_container.hpp
- task_container.cpp