Embedded Template Library
1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
task.h
1
/******************************************************************************
2
The MIT License(MIT)
3
4
Embedded Template Library.
5
https://github.com/ETLCPP/etl
6
https://www.etlcpp.com
7
8
Copyright(c) 2017 John Wellbelove
9
10
Permission is hereby granted, free of charge, to any person obtaining a copy
11
of this software and associated documentation files(the "Software"), to deal
12
in the Software without restriction, including without limitation the rights
13
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
14
copies of the Software, and to permit persons to whom the Software is
15
furnished to do so, subject to the following conditions :
16
17
The above copyright notice and this permission notice shall be included in all
18
copies or substantial portions of the Software.
19
20
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
23
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
SOFTWARE.
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
38
namespace
etl
39
{
40
//***************************************************************************
42
//***************************************************************************
43
class
task_exception :
public
etl::exception
44
{
45
public
:
46
47
task_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
48
:
etl::exception
(reason_, file_name_, line_number_)
49
{
50
}
51
};
52
53
typedef
uint_least8_t task_priority_t;
54
55
//***************************************************************************
57
//***************************************************************************
58
class
task
59
{
60
public
:
61
62
//*******************************************
64
//*******************************************
65
task
(task_priority_t priority)
66
: task_running(true)
67
, task_priority(priority)
68
{
69
}
70
71
//*******************************************
73
//*******************************************
74
virtual
~task
() {}
75
76
//*******************************************
79
//*******************************************
80
virtual
uint32_t
task_request_work
()
const
= 0;
81
82
//*******************************************
84
//*******************************************
85
virtual
void
task_process_work
() = 0;
86
87
//*******************************************
89
//*******************************************
90
virtual
void
on_task_added
()
91
{
92
// Do nothing.
93
}
94
95
//*******************************************
97
//*******************************************
98
void
set_task_running
(
bool
task_running_)
99
{
100
task_running = task_running_;
101
}
102
103
//*******************************************
105
//*******************************************
106
bool
task_is_running
()
const
107
{
108
return
task_running;
109
}
110
111
//*******************************************
114
//*******************************************
115
etl::task_priority_t
get_task_priority
()
const
116
{
117
return
task_priority;
118
}
119
120
private
:
121
122
bool
task_running;
123
etl::task_priority_t task_priority;
124
};
125
}
// namespace etl
126
127
#endif
etl::task::set_task_running
void set_task_running(bool task_running_)
Set the running state for the task.
Definition
task.h:98
etl::task::on_task_added
virtual void on_task_added()
Called when the task has been added to the scheduler.
Definition
task.h:90
etl::task::task_request_work
virtual uint32_t task_request_work() const =0
etl::task::get_task_priority
etl::task_priority_t get_task_priority() const
Definition
task.h:115
etl::task::task
task(task_priority_t priority)
Constructor.
Definition
task.h:65
etl::task::~task
virtual ~task()
Destructor.
Definition
task.h:74
etl::task::task_is_running
bool task_is_running() const
Get the running state for the task.
Definition
task.h:106
etl::task::task_process_work
virtual void task_process_work()=0
Called to get the task to do work.
error_handler.h
exception.h
etl::exception
Definition
exception.h:59
etl
Definition
absolute.h:40
platform.h
include
etl
task.h
Generated on
for Embedded Template Library by
1.17.0