#include <scheduler.h>
Public Types | |
typedef std::list< Task * > | list_type |
Type of the list of tasks. | |
Public Member Functions | |
Scheduler () | |
Default constructor. | |
Scheduler (Scheduler const &s) | |
Copy constructor. | |
Scheduler & | operator= (Scheduler const &right) |
Assignment operator. | |
int | register_type () |
Registers a task type. | |
bool | add (Task &task) |
Adds a task. | |
bool | remove (Task &task) |
Removes a task. | |
list_type::size_type | remove_bytype (int type) |
Removes all tasks of a given type. | |
list_type::size_type | remove_byname (int type, std::string const &name) |
Removes all tasks with the given name and type. | |
bool | run () |
Runs tasks. | |
list_type::size_type | run_bytype (int type) |
Runs tasks of the given type. | |
list_type::size_type | run_byname (int type, std::string const &name) |
Runs tasks with the given name and type. | |
list_type const & | tasks () const |
Returns the list of tasks. | |
Task const * | current_task () const |
Returns the current task being run by the scheduler (0 if none). |
int scheduler::Scheduler::register_type | ( | ) | [inline] |
bool scheduler::Scheduler::add | ( | Task & | task | ) |
Adds a task to the list of scheduled tasks.
[in] | task | The task to be added. |
bool scheduler::Scheduler::remove | ( | Task & | task | ) |
Removes a task from the list of scheduled tasks.
[in] | task | The task to be removed. The function doesn't free the memory pointed by task; it is the caller's responsibility. |
list_type::size_type scheduler::Scheduler::remove_bytype | ( | int | type | ) |
Removes all tasks of a given type from the list of scheduled tasks. operator delete is called for each removed task.
[in] | type | The type of the tasks to be removed. |
list_type::size_type scheduler::Scheduler::remove_byname | ( | int | type, | |
std::string const & | name | |||
) |
Removes all tasks with the given name and type from the list of scheduled tasks. operator delete is called for each removed task.
[in] | type | The type of the tasks to be removed. |
[in] | name | The name of the tasks to be removed. |
bool scheduler::Scheduler::run | ( | ) |
Iterates once in the list of tasks, calling Task::poll() on each task. For tasks that need to be run, Task::run() is called, and the task is either removed or left alone depending on the return value.
list_type::size_type scheduler::Scheduler::run_bytype | ( | int | type | ) |
Iterates once in the list of tasks, calling Task::run() on each task of the given type. The task is either removed or left alone depending on the return value. Task::poll() is NOT called to determine whether the task should be run or not.
[in] | type | The type of the tasks to be run. |
list_type::size_type scheduler::Scheduler::run_byname | ( | int | type, | |
std::string const & | name | |||
) |
Iterates once in the list of tasks, calling Task::run() on each task with the given name and type. The task is either removed or left alone depending on the return value. Task::poll() is NOT called to determine whether the task should be run or not.
[in] | type | The type of the tasks to be run. |
[in] | name | The name of the tasks to be run. |