1
0
Fork 0
mirror of https://gitlab.com/niansa/cosched.git synced 2025-03-06 20:53:26 +01:00
cosched/test.cpp
2023-05-04 10:38:09 +02:00

25 lines
612 B
C++

#include "scheduler.hpp"
#include <iostream>
#include <string>
async::result<void> test_task(CoSched::TaskPtr t) {
for (unsigned x = 100; x != 0; x--) {
std::cout << t->get_name() << ": " << x << '\n';
co_await t->yield();
}
}
int main () {
CoSched::Scheduler scheduler;
for (const auto& name : {"A", "B", "C", "D", "E", "F"}) {
auto task = scheduler.create_task(name);
async::detach(test_task(task));
if (task->get_name() == "B" || task->get_name() == "D") {
task->set_priority(CoSched::PRIO_HIGH);
}
}
scheduler.run();
}