TaskManager
Constructor
TaskManager()
Construct a new TaskManager
object.
- Prototype
- Example
TaskManager();
lightning::TaskManager Auton_tasks;
void autonomous(){
}
Functions
start_task()
Start a task passing a void function.
- Prototype
- Example
void start_task(const std::string &task_name, void (*func)(void *));
//Some function that we want to put into the task manager
void print_stats(void*){
while(1){
//Do some printing stuff
pros::delay(10); //Important to prevent bugs.
}
}
lightning::TaskManager Auton_tasks;
void autonomous(){
Auton_tasks.start_task("PRINTING", print_stats);
}
Parameters | |
---|---|
task_name | The name key that you want for your task. |
function | The void function that will pass. |
kill_task()
Erases a selected task.
- Prototype
- Example
void kill_task(const std::string &task_name);
//Some function that we want to put into the task manager
void print_stats(void*){
while(1){
//Do some printing stuff
pros::delay(10); //Important to prevent bugs.
}
}
lightning::TaskManager Auton_tasks;
void autonomous(){
Auton_tasks.start_task("PRINTING", print_stats);
/*
Doing some stuff during autonomous period
---
--
-
---
--
*/
//We can delete the "PRINTING" task
Auton_tasks.kill_task("PRINTING"); //Deleting the task.
}
Parameters | |
---|---|
task_name | The name key that you want for your task. |
print_current_task()
Prints the current task thar are currently running in Integrated Terminal.
- Prototype
- Example
void print_current_tasks();
//Our functions
void print_stats(void*){
while(1){
//Do some printing stuff
pros::delay(10); //Important to prevent bugs.
}
}
void sensing_something(void*){
while(1){
//Do some sensing stuff
pros::delay(10); //Important to prevent bugs.
}
}
lightning::TaskManager Auton_tasks;
void autonomous(){
Auton_tasks.start_task("PRINTING", print_stats);
Auton_tasks.start_task("SENSING",sensing_something);
/*
Doing some stuff during autonomous period
---
--
*/
Auton_tasks.print_current_tasks();
/*OUTPUT Of print_current_tasks
PRINTING
SENSING
*/
}
Operators
std::ostream &operator <<
Prints the current tasks in Integrated Terminal.
- Prototype
- Example
std::ostream &operator<<(std::ostream &os, const TaskManager &task_manager);
//Our functions
void print_stats(void*){
while(1){
//Do some printing stuff
pros::delay(10); //Important to prevent bugs.
}
}
void sensing_something(void*){
while(1){
//Do some sensing stuff
pros::delay(10); //Important to prevent bugs.
}
}
lightning::TaskManager Auton_tasks;
void autonomous(){
Auton_tasks.start_task("PRINTING", print_stats);
Auton_tasks.start_task("SENSING",sensing_something);
/*
Doing some stuff during autonomous period
---
--
*/
std::cout<<Auton_tasks;
/*OUTPUT Of print_current_tasks
PRINTING
SENSING
*/
}