1
0
Fork 0
mirror of https://gitlab.com/niansa/cosched.git synced 2025-03-06 20:53:26 +01:00

Added get_state_string()

This commit is contained in:
niansa 2023-05-10 14:46:25 +02:00
parent e38e792adc
commit abfddec29c
2 changed files with 17 additions and 0 deletions

View file

@ -32,6 +32,9 @@ enum class TaskState {
};
std::string_view get_state_string(TaskState);
class Task {
friend class Scheduler;
@ -84,6 +87,9 @@ public:
TaskState get_state() const {
return state;
}
std::string_view get_state_string() const {
return ::CoSched::get_state_string(state);
}
// Returns the scheduler that is scheduling this task
Scheduler& get_scheduler() const {

View file

@ -6,6 +6,17 @@
namespace CoSched {
std::string_view get_state_string(TaskState state) {
switch (state) {
case TaskState::dead: return "dead";
case TaskState::running: return "running";
case TaskState::sleeping: return "sleeping";
case TaskState::terminating: return "terminating";
default: return "invalid";
}
}
void CoSched::Task::kill() {
get_scheduler().delete_task(this);
}