F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
101  Status _delay(Fw::TimeInterval interval) override;
102 
105  TaskHandle* getHandle() override;
106  PRIVATE:
115  Status create(const Os::Task::Arguments& arguments, const PosixTask::PermissionExpectation permissions);
116 
117  PosixTaskHandle m_handle;
118  static std::atomic<bool> s_permissions_reported;
119  };
120 } // end namespace Task
121 } // end namespace Posix
122 } // end namespace Os
123 #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:210
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 _delay(Fw::TimeInterval interval) override
delay the current task
Definition: Task.cpp:219
Status join() override
block until the task has ended
Definition: Task.cpp:193
~PosixTask()=default
default virtual destructor
void resume() override
resume a suspended task
Definition: Task.cpp:214
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:204
void onStart() override
perform required task start actions
Definition: Task.cpp:161
Status start(const Arguments &arguments) override
start the task
Definition: Task.cpp:163
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