Embedded Template Library 1.0
Loading...
Searching...
No Matches
task.h
1/******************************************************************************
2The MIT License(MIT)
3
4Embedded Template Library.
5https://github.com/ETLCPP/etl
6https://www.etlcpp.com
7
8Copyright(c) 2017 John Wellbelove
9
10Permission is hereby granted, free of charge, to any person obtaining a copy
11of this software and associated documentation files(the "Software"), to deal
12in the Software without restriction, including without limitation the rights
13to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
14copies of the Software, and to permit persons to whom the Software is
15furnished to do so, subject to the following conditions :
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26SOFTWARE.
27******************************************************************************/
28
29#ifndef ETL_TASK_INCLUDED
30#define ETL_TASK_INCLUDED
31
32#include "platform.h"
33#include "error_handler.h"
34#include "exception.h"
35
36#include <stdint.h>
37
38namespace etl
39{
40 //***************************************************************************
42 //***************************************************************************
52
54
55 //***************************************************************************
57 //***************************************************************************
58 class task
59 {
60 public:
61
62 //*******************************************
64 //*******************************************
66 : task_running(true),
67 task_priority(priority)
68 {
69 }
70
71 //*******************************************
73 //*******************************************
74 virtual ~task()
75 {
76 }
77
78 //*******************************************
81 //*******************************************
82 virtual uint32_t task_request_work() const = 0;
83
84 //*******************************************
86 //*******************************************
87 virtual void task_process_work() = 0;
88
89 //*******************************************
91 //*******************************************
92 virtual void on_task_added()
93 {
94 // Do nothing.
95 }
96
97 //*******************************************
99 //*******************************************
101 {
102 task_running = task_running_;
103 }
104
105 //*******************************************
107 //*******************************************
108 bool task_is_running() const
109 {
110 return task_running;
111 }
112
113 //*******************************************
116 //*******************************************
118 {
119 return task_priority;
120 }
121
122 private:
123
124 bool task_running;
125 etl::task_priority_t task_priority;
126 };
127}
128
129#endif
Base exception class for task.
Definition task.h:44
Task.
Definition task.h:59
void set_task_running(bool task_running_)
Set the running state for the task.
Definition task.h:100
virtual void on_task_added()
Called when the task has been added to the scheduler.
Definition task.h:92
virtual uint32_t task_request_work() const =0
etl::task_priority_t get_task_priority() const
Definition task.h:117
task(task_priority_t priority)
Constructor.
Definition task.h:65
virtual ~task()
Destructor.
Definition task.h:74
bool task_is_running() const
Get the running state for the task.
Definition task.h:108
virtual void task_process_work()=0
Called to get the task to do work.
Definition exception.h:47
bitset_ext
Definition absolute.h:38
pair holds two objects of arbitrary type
Definition utility.h:164