#include <scheduler.h>
Public Types | |
typedef list_type::size_type | size_type |
Size type. | |
typedef list_type::const_iterator | iterator |
Task list iterator. | |
typedef list_type::const_iterator | const_iterator |
Task list constant iterator. | |
typedef list_type::const_reverse_iterator | reverse_iterator |
Task list reverse iterator. | |
typedef list_type::const_reverse_iterator | const_reverse_iterator |
Task list constant reverse iterator. | |
Public Member Functions | |
Scheduler () | |
Default constructor. | |
Scheduler (Scheduler const &s) | |
Copy constructor. | |
Scheduler & | operator= (Scheduler const &right) |
Assignment operator. | |
bool | add (Task &task) |
Adds a task. | |
void | remove (Task &task) |
Removes a task. | |
size_type | remove_bymodule (modules::Module const *module, bool free=false) |
Removes all tasks belonging to a given module. | |
size_type | remove_byname (modules::Module const *module, std::string const &name, bool free=false) |
Removes all tasks with a name belonging to a module. | |
bool | run () |
Runs tasks. | |
size_type | run_bymodule (modules::Module const *module) |
Runs tasks belonging to a module. | |
size_type | run_byname (modules::Module const *module, std::string const &name) |
Runs tasks with a given name belonging to a module. | |
Task const * | current_task () const |
Returns the current task being run by the scheduler (0 if none). | |
iterator | begin () |
Returns the first iterator of the tasks list. | |
const_iterator | begin () const |
Same, const version. | |
iterator | end () |
Returns the last iterator of the tasks list. | |
const_iterator | end () const |
Same, const version. | |
reverse_iterator | rbegin () |
Returns the first reverse iterator of the tasks list. | |
const_reverse_iterator | rbegin () const |
Same, const version. | |
reverse_iterator | rend () |
Returns the last reverse iterator of the tasks list. | |
const_reverse_iterator | rend () const |
Same, const version. | |
bool | empty () const |
Returns whether there are tasks in the scheduler. | |
list_type::size_type | size () const |
Returns the number of tasks in the scheduler. |
bool scheduler::Scheduler::add | ( | Task & | task | ) |
Adds a task to the list of scheduled tasks. When the module the task belongs to is unloaded, the task is automatically removed from the scheduler, though it is still the module responsibility to dispose of it.
[in] | task | The task to be added. |
void 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. |
size_type scheduler::Scheduler::remove_bymodule | ( | modules::Module const * | module, | |
bool | free = false | |||
) |
Removes all tasks belonging to a given module from the list of scheduled tasks.
The core module calls removeby_module(module, false) when a module is being unloaded.
[in] | module | The module whose tasks must be removed. |
[in] | free | Whether operator delete must be called on tasks before removing them. |
size_type scheduler::Scheduler::remove_byname | ( | modules::Module const * | module, | |
std::string const & | name, | |||
bool | free = false | |||
) |
Removes all tasks with the given name belonging to the given module from the list of scheduled tasks.
[in] | module | The module whose tasks must be removed. |
[in] | name | The name of the tasks to be removed. |
[in] | free | Whether operator delete must be called on tasks before removing them. |
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.
size_type scheduler::Scheduler::run_bymodule | ( | modules::Module const * | module | ) |
Iterates once in the list of tasks, calling Task::run() on each task belonging to the given module. The task might then be removed depending on the return value. Task::poll() is NOT called to determine whether the task should be run or not.
[in] | module | The module whose tasks must be run. |
size_type scheduler::Scheduler::run_byname | ( | modules::Module const * | module, | |
std::string const & | name | |||
) |
Iterates once in the list of tasks, calling Task::run() on each task with the given name belonging to the given module. The task might then be removed depending on the return value. Task::poll() is NOT called to determine whether the task should be run or not.
[in] | module | The module whose tasks must be run. |
[in] | name | The name of the tasks to be run. |