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:
parent
e38e792adc
commit
abfddec29c
2 changed files with 17 additions and 0 deletions
|
@ -32,6 +32,9 @@ enum class TaskState {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
std::string_view get_state_string(TaskState);
|
||||||
|
|
||||||
|
|
||||||
class Task {
|
class Task {
|
||||||
friend class Scheduler;
|
friend class Scheduler;
|
||||||
|
|
||||||
|
@ -84,6 +87,9 @@ public:
|
||||||
TaskState get_state() const {
|
TaskState get_state() const {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
std::string_view get_state_string() const {
|
||||||
|
return ::CoSched::get_state_string(state);
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the scheduler that is scheduling this task
|
// Returns the scheduler that is scheduling this task
|
||||||
Scheduler& get_scheduler() const {
|
Scheduler& get_scheduler() const {
|
||||||
|
|
|
@ -6,6 +6,17 @@
|
||||||
|
|
||||||
|
|
||||||
namespace CoSched {
|
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() {
|
void CoSched::Task::kill() {
|
||||||
get_scheduler().delete_task(this);
|
get_scheduler().delete_task(this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue