F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
Task.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Os/Posix/Task.hpp
3 // \brief definitions of Posix implementation of Os::Task
4 // ======================================================================
5 #ifndef Os_Posix_Task_hpp_
6 #define Os_Posix_Task_hpp_
7 
8 #include <atomic>
9 #include <pthread.h>
10 #include <Os/Task.hpp>
11 
12 #include <FpConfig.hpp>
14 #include <Os/TaskString.hpp>
15 #include <Os/Mutex.hpp>
16 #include <Fw/Deprecate.hpp>
17 
18 namespace Os {
19 namespace Posix {
20 namespace Task {
21 
24  struct PosixTaskHandle : public TaskHandle {
25  static constexpr PlatformIntType SUCCESS = 0;
26 
28  pthread_t m_task_descriptor;
30  bool m_is_valid = false;
31  };
32 
34  class PosixTask : public TaskInterface {
35  public:
36 
41  };
42 
44  PosixTask() = default;
45 
47  ~PosixTask() = default;
48 
50  PosixTask(const PosixTask& other) = delete;
51 
53  PosixTask& operator=(const PosixTask& other) = delete;
54 
55 
57  void onStart() override;
58 
64  //
69  Status start(const Arguments& arguments) override;
70 
77  Status join() override;
78 
86  void suspend(SuspensionType suspensionType) override;
87 
92  void resume() override;
93 
96  TaskHandle* getHandle() override;
97  PRIVATE:
106  Status create(const Os::Task::Arguments& arguments, const PosixTask::PermissionExpectation permissions);
107 
108  PosixTaskHandle m_handle;
109  static std::atomic<bool> s_permissions_reported;
110  };
111 } // end namespace Task
112 } // end namespace Posix
113 } // end namespace Os
114 #endif
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
C++-compatible configuration header for fprime configuration.
Posix task implementation as driven by pthreads implementation.
Definition: Task.hpp:34
void suspend(SuspensionType suspensionType) override
suspend the task given the suspension type
Definition: Task.cpp:205
PermissionExpectation
Enumeration of permission expectations.
Definition: Task.hpp:38
@ EXPECT_NO_PERMISSION
Expect that you do not hold necessary permissions.
Definition: Task.hpp:40
@ EXPECT_PERMISSION
Expect that you hold necessary permissions.
Definition: Task.hpp:39
Status join() override
block until the task has ended
Definition: Task.cpp:188
~PosixTask()=default
default virtual destructor
void resume() override
resume a suspended task
Definition: Task.cpp:209
PosixTask()=default
default constructor
PosixTask(const PosixTask &other)=delete
copy constructor is forbidden
PosixTask & operator=(const PosixTask &other)=delete
assignment operator is forbidden
TaskHandle * getHandle() override
return the underlying task handle (implementation specific)
Definition: Task.cpp:199
void onStart() override
perform required task start actions
Definition: Task.cpp:156
Status start(const Arguments &arguments) override
start the task
Definition: Task.cpp:158
Task handle representation.
Definition: Task.hpp:24
static constexpr PlatformIntType SUCCESS
Definition: Task.hpp:25
pthread_t m_task_descriptor
Posix task descriptor.
Definition: Task.hpp:28
bool m_is_valid
Is the above descriptor valid.
Definition: Task.hpp:30