Line |
Branch |
Exec |
Source |
1 |
|
|
/** |
2 |
|
|
* @file api.Task.hpp |
3 |
|
|
* @author Sergey Baigudin, sergey@baigudin.software |
4 |
|
|
* @copyright 2016-2022, Sergey Baigudin, Baigudin Software |
5 |
|
|
*/ |
6 |
|
|
#ifndef API_TASK_HPP_ |
7 |
|
|
#define API_TASK_HPP_ |
8 |
|
|
|
9 |
|
|
#include "api.Object.hpp" |
10 |
|
|
|
11 |
|
|
namespace eoos |
12 |
|
|
{ |
13 |
|
|
namespace api |
14 |
|
|
{ |
15 |
|
|
|
16 |
|
|
/** |
17 |
|
|
* @class Task |
18 |
|
|
* @brief Task interface. |
19 |
|
|
* |
20 |
|
|
* The interface of a task that is being executed in self context. |
21 |
|
|
*/ |
22 |
|
|
class Task : public Object |
23 |
|
|
{ |
24 |
|
|
|
25 |
|
|
public: |
26 |
|
|
|
27 |
|
|
/** |
28 |
|
|
* @brief Destructor. |
29 |
|
|
*/ |
30 |
|
|
virtual ~Task() = 0; |
31 |
|
|
|
32 |
|
|
/** |
33 |
|
|
* @brief Starts executing an operating system task in itself context. |
34 |
|
|
*/ |
35 |
|
|
virtual void start() = 0; |
36 |
|
|
|
37 |
|
|
/** |
38 |
|
|
* @brief Returns size of stack. |
39 |
|
|
* |
40 |
|
|
* The function returns size of stack in bytes which should be allocated for the task. |
41 |
|
|
* |
42 |
|
|
* @note POSIX thread won't be created if the stack size is less than PTHREAD_STACK_MIN (16384) bytes. |
43 |
|
|
* On some systems, thread creation can fail with if stacksize is not a multiple of the system page size. |
44 |
|
|
* |
45 |
|
|
* |
46 |
|
|
* @return Stack size in bytes, or zero if OS default stack size is needed. |
47 |
|
|
*/ |
48 |
|
|
virtual size_t getStackSize() const = 0; |
49 |
|
|
|
50 |
|
|
}; |
51 |
|
|
|
52 |
|
132 |
inline Task::~Task() {} |
53 |
|
|
|
54 |
|
|
} // namespace api |
55 |
|
|
} // namespace eoos |
56 |
|
|
#endif // API_TASK_HPP_ |
57 |
|
|
|