29 #ifndef ETL_SCHEDULER_INCLUDED
30 #define ETL_SCHEDULER_INCLUDED
111 for (
size_t index = 0; index < task_list.
size(); ++index)
140 for (
size_t index = 0; index < task_list.
size(); ++index)
170 while (index < task_list.
size())
202 size_t most_index = 0;
203 uint32_t most_work = 0;
205 for (
size_t index = 0; index < task_list.
size(); ++index)
211 if (n_work > most_work)
221 task_list[most_index]->task_process_work();
238 virtual void start() = 0;
265 scheduler_running = scheduler_running_;
273 return scheduler_running;
281 scheduler_exit =
true;
292 if (!task_list.
full())
294 typename task_list_t::iterator itask = etl::upper_bound(task_list.
begin(),
310 template <
typename TSize>
313 for (TSize i = 0; i < size; ++i)
327 : scheduler_running(false),
328 scheduler_exit(false),
329 p_idle_callback(ETL_NULLPTR),
330 p_watchdog_callback(ETL_NULLPTR),
331 task_list(task_list_)
335 bool scheduler_running;
345 struct compare_priority
347 bool operator()(etl::task_priority_t priority,
etl::task* ptask)
const
354 task_list_t& task_list;
360 template <
typename TSchedulerPolicy,
size_t MAX_TASKS_>
367 MAX_TASKS = MAX_TASKS_,
382 scheduler_running =
true;
384 while (!scheduler_exit)
386 if (scheduler_running)
388 bool idle = TSchedulerPolicy::schedule_tasks(task_list);
390 if (p_watchdog_callback)
392 (*p_watchdog_callback)();
395 if (idle && p_idle_callback)
397 (*p_idle_callback)();
406 task_list_t task_list;
Definition: callback.h:45
Scheduler base.
Definition: scheduler.h:232
void add_task_list(etl::task **p_tasks, TSize size)
Definition: scheduler.h:311
ischeduler(etl::ivector< etl::task * > &task_list_)
Constructor.
Definition: scheduler.h:326
void set_watchdog_callback(etl::ifunction< void > &callback)
Set the watchdog callback.
Definition: scheduler.h:255
void exit_scheduler()
Force the scheduler to exit.
Definition: scheduler.h:279
void set_scheduler_running(bool scheduler_running_)
Set the running state for the scheduler.
Definition: scheduler.h:263
void add_task(etl::task &task)
Definition: scheduler.h:288
void set_idle_callback(etl::ifunction< void > &callback)
Set the idle callback.
Definition: scheduler.h:247
bool scheduler_is_running() const
Get the running state for the scheduler.
Definition: scheduler.h:271
Base exception class for scheduler.
Definition: scheduler.h:52
'No tasks' exception.
Definition: scheduler.h:65
'Null tasks' exception.
Definition: scheduler.h:78
'Too many tasks' exception.
Definition: scheduler.h:91
Scheduler.
Definition: scheduler.h:362
void start()
Start the scheduler.
Definition: scheduler.h:378
Task.
Definition: task.h:62
virtual void on_task_added()
Called when the task has been added to the scheduler.
Definition: task.h:95
virtual uint32_t task_request_work() const =0
etl::task_priority_t get_task_priority() const
Definition: task.h:120
virtual void task_process_work()=0
Called to get the task to do work.
#define ETL_ASSERT(b, e)
Definition: error_handler.h:290
Definition: exception.h:47
Definition: function.h:73
iterator begin()
Definition: vector.h:108
iterator insert(iterator position, const_reference value)
Definition: vector.h:531
iterator end()
Definition: vector.h:126
bool full() const
Definition: vector.h:914
size_type size() const
Definition: vector.h:896
Definition: absolute.h:37
ETL_DEPRECATED typedef scheduler_policy_sequential_multiple scheduler_policy_sequencial_multiple
Typedef for backwards compatibility with miss-spelt struct name.
Definition: scheduler.h:156
ETL_DEPRECATED_REASON("Misspelt class name") typedef scheduler_policy_sequential_single scheduler_policy_sequencial_single
Typedef for backwards compatibility with miss-spelt struct name.
Definition: scheduler.h:164
Definition: scheduler.h:197
Definition: scheduler.h:135
Definition: scheduler.h:106