std1.0.0-beta-7 SafeC docs

std :: sync::task

Trait std::TaskRunner

#include <std/sync/task.h> source

trait TaskRunner {
    int tick();
    void run_all();
    int active_count() const;
}

What a cooperative scheduler offers to the code driving it: one round, run to completion, and how many tasks are left. TaskScheduler and ThreadSched (thread_bare.h, priority-ordered) both conform, so a driver loop written once against TaskRunner runs either. Spawning isn't part of it: ThreadSched::spawn takes a priority that TaskScheduler::spawn has no place for. (Not called Scheduler: that's kernel/scheduler.h's struct.)

Required methods

§int tick()source

one round; returns the still-active count

§void run_all()source

until every task is done

§int active_count() constsource