| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title Os/Stub/Task.hpp | ||
| 3 | // \brief stub definitions for Os::Task | ||
| 4 | // ====================================================================== | ||
| 5 | #include "Os/Task.hpp" | ||
| 6 | |||
| 7 | #ifndef OS_STUB_TASK_HPP | ||
| 8 | #define OS_STUB_TASK_HPP | ||
| 9 | namespace Os { | ||
| 10 | namespace Stub { | ||
| 11 | namespace Task { | ||
| 12 | |||
| 13 | //! Test task handle | ||
| 14 | class StubTaskHandle : public TaskHandle {}; | ||
| 15 | |||
| 16 | //! Implementation of task | ||
| 17 | class StubTask : public TaskInterface { | ||
| 18 | public: | ||
| 19 | //! Constructor | ||
| 20 | 1 | StubTask() = default; | |
| 21 | |||
| 22 | //! Destructor | ||
| 23 | 2 | ~StubTask() override = default; | |
| 24 | |||
| 25 | //! \brief perform required task start actions | ||
| 26 | void onStart() override; | ||
| 27 | |||
| 28 | //! \brief block until the task has ended | ||
| 29 | //! | ||
| 30 | //! Blocks the current (calling) task until this task execution has ended. Callers should ensure that any | ||
| 31 | //! signals required to stop this task have already been emitted or will be emitted by another task. | ||
| 32 | //! | ||
| 33 | //! \return status of the block | ||
| 34 | Status join() override; | ||
| 35 | |||
| 36 | //! \brief suspend the task given the suspension type | ||
| 37 | //! | ||
| 38 | //! Suspends the task. Some implementations track if the suspension of a task was intentional or | ||
| 39 | //! unintentional. The supplied `suspensionType` parameter indicates that this was intentional or | ||
| 40 | //! unintentional. The type of suspension is also returned when calling `isSuspended`. | ||
| 41 | //! | ||
| 42 | //! \param suspensionType intentionality of the suspension | ||
| 43 | void suspend(SuspensionType suspensionType) override; | ||
| 44 | |||
| 45 | //! \brief resume a suspended task | ||
| 46 | //! | ||
| 47 | //! Resumes this task. Not started, running, and exited tasks take no action. | ||
| 48 | //! | ||
| 49 | void resume() override; | ||
| 50 | |||
| 51 | //! \brief delay the current task | ||
| 52 | //! | ||
| 53 | //! Delays, or sleeps, the current task by the supplied time interval. In non-preempting os implementations | ||
| 54 | //! the task will resume no earlier than expected but an exact wake-up time is not guaranteed. | ||
| 55 | //! | ||
| 56 | //! \param interval: delay time | ||
| 57 | //! \return status of the delay | ||
| 58 | Status _delay(const Fw::TimeInterval& interval) override; | ||
| 59 | |||
| 60 | //! \brief return the underlying task handle (implementation specific) | ||
| 61 | //! \return internal task handle representation | ||
| 62 | TaskHandle* getHandle() override; | ||
| 63 | |||
| 64 | //! \brief determine if the task requires cooperative multitasking | ||
| 65 | //! | ||
| 66 | //! Some task implementations require cooperative multitasking where the task execution is run by a user | ||
| 67 | //! defined task scheduler and not the operating system task scheduler. These tasks cooperatively on | ||
| 68 | //! multitask by doing one unit of work and return from the function. | ||
| 69 | //! | ||
| 70 | //! This function indicates if the task requires cooperative support. | ||
| 71 | //! The default implementation returns false. | ||
| 72 | //! | ||
| 73 | //! \return true when the task expects cooperation, false otherwise | ||
| 74 | bool isCooperative() override; | ||
| 75 | |||
| 76 | //! \brief start the task | ||
| 77 | //! | ||
| 78 | //! Starts the task given the supplied arguments. | ||
| 79 | //! | ||
| 80 | //! \param arguments: arguments supplied to the task start call | ||
| 81 | //! \return status of the task start | ||
| 82 | Status start(const Arguments& arguments) override; | ||
| 83 | }; | ||
| 84 | |||
| 85 | } // namespace Task | ||
| 86 | } // namespace Stub | ||
| 87 | } // namespace Os | ||
| 88 | #endif // End OS_STUB_TASK_HPP | ||
| 89 |