|
fiber
|
A real time scheduler that starts tasks once they are ready and schedules them by earliest deadline first. More...
#include <Scheduler.hpp>
Public Member Functions | |
| Scheduler (TimePoint(*now)(), void(*sleep_until)(TimePoint)=default_sleep_until) | |
| TimePoint | now () const |
| returns the current time | |
| void | add (TaskBase *task) |
| Adds a tasks to the scheduler. | |
| void | spin () |
| Checks the state of Tasks and executes one if ready. | |
| constexpr size_t | capacity () const |
| returns the capacity of the scheduler | |
| constexpr size_t | max_size () const |
| returns the maximal number of tasks that this scheduler can manage. | |
| constexpr size_t | n_waiting () const |
| returns the number of tasks currently in the waiting queue | |
| constexpr size_t | n_running () const |
| returns the number of tasks currently in the running queue | |
| constexpr size_t | n_awaiting () const |
| returns the number of tasks currently in the awaiting queue | |
| constexpr size_t | size () const |
| returns the current number of tasks that this scheduler manages. | |
| constexpr size_t | reserve () const |
| returns the remaining number of tasks that can still added to the scheduler | |
| constexpr bool | is_waiting () const |
returns true if there are no tasks in its running queue | |
| constexpr bool | is_busy () const |
returns true if there are tasks in its running queue and false if the scheduler is waiting. | |
| constexpr bool | is_empty () const |
returns true if there are no tasks in any queue | |
| constexpr bool | is_full () const |
returns true if the scheduler is full, the scheduler cannot handle more tasks, no more tasks can be added to the scheduler safely. | |
| constexpr bool | is_done () const |
returns true if there are no tasks in the sheduler | |
| void | print (OStream &stream) const |
| prints the current state of the scheduler. Lists all queues and contained tasks. | |
| void | print (OStreamRef stream) |
Friends | |
| OStream & | operator<< (OStream &stream, const Scheduler &scheduler) |
| prints the state of the scheduler. Lists all queues and their contained tasks. | |
A real time scheduler that starts tasks once they are ready and schedules them by earliest deadline first.
Manages three lists of tasks:
| n_tasks | The maximum number of thats that will be pre-allocated for this scheduler. |
| logger | A logger that implements the functions defined by fiber::CSchedulerLogger |
|
inline |
|
inline |
Adds a tasks to the scheduler.
Assigns an unique-ID to the task and adds it either to the 'running' or 'waiting' queue.
| Throws | an AssertionFailureO1 if FIBER_ASSERTION_LEVEL_O1 or higher is enabled, if the task could not be added and the scheduler is already full. |
|
inlineconstexpr |
returns the capacity of the scheduler
The capacity represents the number of total tasks that can be added without reallocation. For static schedulers (like this one) .capacity() is equivalent to .max_size().
To increase the capacity increase the template parameter n_tasks.
|
inlineconstexpr |
returns true if there are tasks in its running queue and false if the scheduler is waiting.
|
inlineconstexpr |
returns true if there are no tasks in the sheduler
|
inlineconstexpr |
returns true if there are no tasks in any queue
|
inlineconstexpr |
returns true if the scheduler is full, the scheduler cannot handle more tasks, no more tasks can be added to the scheduler safely.
|
inlineconstexpr |
returns true if there are no tasks in its running queue
|
inlineconstexpr |
returns the maximal number of tasks that this scheduler can manage.
To increase the max_size() increase the template parameter n_tasks.
|
inlineconstexpr |
returns the number of tasks currently in the awaiting queue
Tasks that are in the awaiting queue are waiting for a future or awaitable to become ready.
|
inlineconstexpr |
returns the number of tasks currently in the running queue
Tasks that are in the ready queue are all tasks that have a ready time that is larger than this->now().
|
inlineconstexpr |
returns the number of tasks currently in the waiting queue
Tasks that are in the waiting queue are waiting for time to pass until this->now() is larger than the ready time of a task.
|
inline |
returns the current time
Uses the function passed at construction
|
inline |
prints the current state of the scheduler. Lists all queues and contained tasks.
Example output:
| stream | A reference to an fiber::OStream object |
|
inline |
|
inlineconstexpr |
returns the remaining number of tasks that can still added to the scheduler
|
inlineconstexpr |
returns the current number of tasks that this scheduler manages.
|
inline |
Checks the state of Tasks and executes one if ready.
First promotes tasks from the waiting-queue or the awaiting-queue to the running-queue if they are ready. Then runs the next task with the earliest deadline
|
friend |
prints the state of the scheduler. Lists all queues and their contained tasks.