76 void*
const routine_argument =
nullptr,
208 static void run(
void* task_pointer);
367 static
Mutex s_taskMutex;
375 bool m_registered = false;
unsigned int PlatformUIntType
#define FW_HANDLE_ALIGNMENT
Alignment of handle storage.
PlatformSizeType FwSizeType
C++-compatible configuration header for fprime configuration.
U8 TaskHandleStorage[FW_TASK_HANDLE_MAX_SIZE]
Wrapper for task routine that ensures onStart() is called once the task actually begins.
void invoke()
invoke the run method with "self" as argument
static void run(void *task_pointer)
run the task routine wrapper
void * m_user_argument
Argument to user function.
TaskRoutineWrapper(Task &self)
Task & m_task
Reference to owning task.
taskRoutine m_user_function
User function to run once started.
Task handle representation.
static FwSizeType getNumTasks()
get the current number of tasks
bool isCooperative() override
determine if the task is cooperative multitasking (implementation specific)
static Status delay(Fw::TimeInterval interval)
delay the current task
DEPRECATED(Status start(const Fw::StringBase &name, const taskRoutine routine, void *const arg=nullptr, const ParamType priority=TASK_DEFAULT, const ParamType stackSize=TASK_DEFAULT, const ParamType cpuAffinity=TASK_DEFAULT, const ParamType identifier=TASK_DEFAULT), "Switch to Task::start(Arguments&)")
start this task
Task()
default constructor
TaskHandle * getHandle() override
return the underlying task handle (implementation specific)
State getState()
get the task's state
FwSizeType getPriority()
get the task priority
FwSizeType ParamType
backwards-compatible parameter type
static Task & getSingleton()
get a reference to singleton
static void init()
initialize singleton
void resume() override
resume a suspended task
void onStart() override
perform delegate's required task start actions
Status _delay(Fw::TimeInterval interval) override
delay the current task
void invokeRoutine()
invoke the task's routine
void suspend()
suspend the current task
static void registerTaskRegistry(TaskRegistry *registry)
register a task registry to track Threads
Status start(const Arguments &arguments) override
start the task
~Task() final
default virtual destructor
Status join() override
block until the task has ended
Arguments(const Fw::StringBase &name, const taskRoutine routine, void *const routine_argument=nullptr, const FwSizeType priority=TASK_DEFAULT, const FwSizeType stackSize=TASK_DEFAULT, const FwSizeType cpuAffinity=TASK_DEFAULT, const PlatformUIntType identifier=static_cast< PlatformUIntType >(TASK_DEFAULT))
construct a set of arguments to start a task
void * m_routine_argument
const Os::TaskString m_name
PlatformUIntType m_identifier
virtual TaskHandle * getHandle()=0
return the underlying task handle (implementation specific)
virtual Status start(const Arguments &arguments)=0
start the task
TaskInterface(const TaskInterface &other)=delete
copy constructor is forbidden
virtual void suspend(SuspensionType suspensionType)=0
suspend the task given the suspension type
virtual Status join()=0
block until the task has ended
virtual void resume()=0
resume a suspended task
TaskInterface()=default
default constructor
virtual Status _delay(Fw::TimeInterval interval)=0
delay the currently scheduled task using the given architecture
static TaskInterface * getDelegate(TaskHandleStorage &aligned_placement_new_memory)
provide a pointer to a task delegate object
static constexpr FwSizeType TASK_DEFAULT
@ SUSPENDED_INTENTIONALLY
@ SUSPENDED_UNINTENTIONALLY
virtual ~TaskInterface()=default
default virtual destructor
void(* taskRoutine)(void *ptr)
Prototype for task routine started in task context.
TaskInterface & operator=(const TaskInterface &other)=delete
assignment operator is forbidden
virtual void onStart()=0
perform required task start actions
@ INVALID_STATE
Task is in an invalid state for the operation.
@ OP_OK
message sent/received okay
@ UNKNOWN_ERROR
unexpected error return value
@ ERROR_PERMISSION
permissions error setting-up tasks
@ INVALID_PARAMS
started task with invalid parameters
@ ERROR_RESOURCES
unable to allocate more tasks
@ DELAY_ERROR
error trying to delay the task
@ INVALID_STACK
started with invalid stack size
@ INVALID_HANDLE
Task handle invalid.
@ INVALID_AFFINITY
unable to set the task affinity
@ JOIN_ERROR
error trying to join the task
virtual bool isCooperative()
determine if the task requires cooperative multitasking
TaskRegistry()=default
default task registry constructor
virtual void addTask(Task *task)=0
add supplied task to the registry
virtual void removeTask(Task *task)=0
remove supplied task to the registry
virtual ~TaskRegistry()=default
default task registry constructor
A class to represent a time interval holding two U32 seconds and microseconds values.