F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Os::TaskCommon< T > Class Template Reference

#include <Os/Task.hpp>

Inheritance diagram for Os::TaskCommon< T >:
Os::TaskUserInterface

Classes

class  TaskRoutineWrapper
 Wrapper for task routine that ensures onStart() is called once the task actually begins. More...
 

Public Types

typedef FwSizeType ParamType
 backwards-compatible parameter type More...
 
- Public Types inherited from Os::TaskUserInterface
enum  Status {
  OP_OK, INVALID_HANDLE, INVALID_PARAMS, INVALID_PRIORITY,
  INVALID_STACK, UNKNOWN_ERROR, INVALID_AFFINITY, DELAY_ERROR,
  JOIN_ERROR, ERROR_RESOURCES, ERROR_PERMISSION, NOT_SUPPORTED,
  INVALID_STATE
}
 
enum  SuspensionType { INTENTIONAL, UNINTENTIONAL }
 
enum  State {
  NOT_STARTED, STARTING, RUNNING, SUSPENDED_INTENTIONALLY,
  SUSPENDED_UNINTENTIONALLY, EXITED, UNKNOWN
}
 
typedef void(* taskRoutine) (void *ptr)
 Prototype for task routine started in task context. More...
 

Public Member Functions

 TaskCommon ()
 default constructor More...
 
 ~TaskCommon ()
 default virtual destructor More...
 
 TaskCommon (const TaskCommon &other)=delete
 copy constructor is forbidden More...
 
TaskCommon & operator= (const TaskCommon &other)=delete
 assignment operator is forbidden More...
 
void suspend ()
 suspend the current task More...
 
State getState () const
 get the task's state More...
 
 DEPRECATED (Status start(const Fw::ConstStringBase &name, const taskRoutine routine, void *const arg=nullptr, const FwTaskPriorityType priority=TASK_PRIORITY_DEFAULT, const ParamType stackSize=TASK_DEFAULT, const ParamType cpuAffinity=TASK_DEFAULT, const ParamType identifier=TASK_DEFAULT), "Switch to Task::start(Arguments&)")
 start this task More...
 
Status start (const Arguments &arguments)
 start the task More...
 
void onStart ()
 perform delegate's required task start actions More...
 
void invokeRoutine ()
 invoke the task's routine More...
 
 DEPRECATED (Status join(void **value_ptr), "Please switch to argument free join.")
 join calling thread to this thread More...
 
Status join ()
 block until the task has ended More...
 
void suspend (SuspensionType suspensionType)
 suspend the task given the suspension type More...
 
void resume ()
 resume a suspended task More...
 
Status _delay (const Fw::TimeInterval &interval)
 delay the current task More...
 
bool isCooperative ()
 determine if the task is cooperative multitasking (implementation specific) More...
 
TaskString getName ()
 get the task name More...
 
FwTaskPriorityType getPriority ()
 get the task priority More...
 
TaskHandle * getHandle ()
 return the underlying task handle (implementation specific) More...
 

Static Public Member Functions

static void init ()
 initialize singleton More...
 
static FwSizeType getNumTasks ()
 get the current number of tasks More...
 
static void registerTaskRegistry (TaskRegistry *registry)
 register a task registry to track Threads More...
 
static TaskCommon & getSingleton ()
 get a reference to singleton More...
 
static Status delay (const Fw::TimeInterval &interval)
 delay the current task More...
 

Friends

struct Os::Test::Task::Tester
 

Additional Inherited Members

- Static Public Attributes inherited from Os::TaskUserInterface
static constexpr FwSizeType TASK_DEFAULT = std::numeric_limits<FwSizeType>::max()
 
static constexpr FwTaskPriorityType TASK_PRIORITY_DEFAULT = std::numeric_limits<FwTaskPriorityType>::max()
 

Detailed Description

template<typename T>
class Os::TaskCommon< T >

Task class intended to be used by the rest of the fprime system. This is final as it is not intended to be a parent class. Instead it wraps a delegate of the template type T to provide system specific behaviour.

Definition at line 27 of file Task.hpp.

Member Typedef Documentation

◆ ParamType

template<typename T >
typedef FwSizeType Os::TaskCommon< T >::ParamType

backwards-compatible parameter type

Definition at line 80 of file Task.hpp.

Constructor & Destructor Documentation

◆ TaskCommon() [1/2]

template<typename T >
Os::TaskCommon< T >::TaskCommon ( )

default constructor

Definition at line 320 of file Task.hpp.

◆ ~TaskCommon()

template<typename T >
Os::TaskCommon< T >::~TaskCommon ( )

default virtual destructor

Definition at line 323 of file Task.hpp.

◆ TaskCommon() [2/2]

template<typename T >
Os::TaskCommon< T >::TaskCommon ( const TaskCommon< T > &  other)
delete

copy constructor is forbidden

Member Function Documentation

◆ _delay()

template<typename T >
Os::TaskUserInterface::Status Os::TaskCommon< T >::_delay ( const Fw::TimeInterval &  interval)

delay the current task

Delays, or sleeps, the current task by the supplied time interval. In non-preempting os implementations the task will resume no earlier than expected but an exact wake-up time is not guaranteed.

Parameters
intervaldelay time
Returns
status of the delay

Definition at line 464 of file Task.hpp.

◆ delay()

template<typename T >
Os::TaskUserInterface::Status Os::TaskCommon< T >::delay ( const Fw::TimeInterval &  interval)
static

delay the current task

Delays, or sleeps, the current task by the supplied time interval. In non-preempting os implementations the task will resume no earlier than expected but an exact wake-up time is not guaranteed.

Parameters
intervaldelay time
Returns
status of the delay

Definition at line 469 of file Task.hpp.

◆ DEPRECATED() [1/2]

template<typename T >
Os::TaskCommon< T >::DEPRECATED ( Status   startconst Fw::ConstStringBase &name, const taskRoutine routine, void *const arg=nullptr, const FwTaskPriorityType priority=TASK_PRIORITY_DEFAULT, const ParamType stackSize=TASK_DEFAULT, const ParamType cpuAffinity=TASK_DEFAULT, const ParamType identifier=TASK_DEFAULT,
"Switch to Task::start(Arguments&)"   
)

start this task

Start this task with supplied name, task routine (run function), priority, stack, affinity, and task identifier. These arguments are supplied into an Arguments class and that version of the function is called. It is illegal to supply a nullptr as routine.

Parameters
namename of the task to start
routineuser routine to run
arg(optional) user argument to supply to task routine
priority(optional) priority of this task
stackSize(optional) stack size of this task
cpuAffinity(optional) affinity of this task. Use Task::start(Arguments&) to supply affinity set.
identifier(optional) identifier of this task
Returns
: status of the start call

◆ DEPRECATED() [2/2]

template<typename T >
Os::TaskCommon< T >::DEPRECATED ( Status   joinvoid **value_ptr,
"Please switch to argument free join."   
)

join calling thread to this thread

Note: this function is deprecated as the value_ptr object is not used anyway and should always be set to nullptr.

Parameters
value_ptrmust be set to nullptr
Returns
status of the join

◆ getHandle()

template<typename T >
TaskHandle * Os::TaskCommon< T >::getHandle ( )

return the underlying task handle (implementation specific)

Returns
internal task handle representation

Definition at line 451 of file Task.hpp.

◆ getName()

template<typename T >
TaskString Os::TaskCommon< T >::getName ( )

get the task name

Definition at line 439 of file Task.hpp.

◆ getNumTasks()

template<typename T >
FwSizeType Os::TaskCommon< T >::getNumTasks ( )
static

get the current number of tasks

Returns
current number of tasks

Definition at line 456 of file Task.hpp.

◆ getPriority()

template<typename T >
FwTaskPriorityType Os::TaskCommon< T >::getPriority ( )

get the task priority

Definition at line 445 of file Task.hpp.

◆ getSingleton()

template<typename T >
TaskCommon< T > & Os::TaskCommon< T >::getSingleton ( )
static

get a reference to singleton

Returns
reference to singleton

Definition at line 480 of file Task.hpp.

◆ getState()

template<typename T >
TaskCommon< T >::State Os::TaskCommon< T >::getState ( ) const

get the task's state

Returns the task state: not started, running, suspended (intentionally), suspended (unintentionally), and exited.

Returns
task state

Definition at line 336 of file Task.hpp.

◆ init()

template<typename T >
void Os::TaskCommon< T >::init ( )
static

initialize singleton

Definition at line 474 of file Task.hpp.

◆ invokeRoutine()

template<typename T >
void Os::TaskCommon< T >::invokeRoutine ( )

invoke the task's routine

This will invoke the task's routine passing this as the argument to that call. This is used as a helper when running this task (e.g. repetitive cooperative calls).

Definition at line 398 of file Task.hpp.

◆ isCooperative()

template<typename T >
bool Os::TaskCommon< T >::isCooperative ( )

determine if the task is cooperative multitasking (implementation specific)

Returns
true if cooperative, false otherwise

Definition at line 434 of file Task.hpp.

◆ join()

template<typename T >
TaskCommon< T >::Status Os::TaskCommon< T >::join ( )

block until the task has ended

Blocks the current (calling) task until this task execution has ended. Callers should ensure that any signals required to stop this task have already been emitted or will be emitted by another task.

Returns
status of the block Wait for task to finish

Definition at line 403 of file Task.hpp.

◆ onStart()

template<typename T >
void Os::TaskCommon< T >::onStart ( )

perform delegate's required task start actions

Definition at line 393 of file Task.hpp.

◆ operator=()

template<typename T >
TaskCommon& Os::TaskCommon< T >::operator= ( const TaskCommon< T > &  other)
delete

assignment operator is forbidden

◆ registerTaskRegistry()

template<typename T >
void Os::TaskCommon< T >::registerTaskRegistry ( TaskRegistry *  registry)
static

register a task registry to track Threads

Definition at line 505 of file Task.hpp.

◆ resume()

template<typename T >
void Os::TaskCommon< T >::resume ( )

resume a suspended task

Resumes this task. Not started, running, and exited tasks take no action.

Definition at line 429 of file Task.hpp.

◆ start()

template<typename T >
TaskCommon< T >::Status Os::TaskCommon< T >::start ( const Arguments &  arguments)

start the task

Starts the task given the supplied arguments. This is done via a task routine wrapper intermediary that ensures that setStarted is called once the task has actually started to run. The task then runs the user routine. This function may return before the new task begins to run. It is illegal for arguments.m_routine to be null.

Parameters
argumentsarguments supplied to the task start call
Returns
status of the task start

Definition at line 345 of file Task.hpp.

◆ suspend() [1/2]

template<typename T >
void Os::TaskCommon< T >::suspend ( )

suspend the current task

Suspend the current task unintentionally. If the user needs to indicate that the task was suspended intentionally then a call to suspend(SuspensionType::INTENTIONAL) should be used.

Definition at line 331 of file Task.hpp.

◆ suspend() [2/2]

template<typename T >
void Os::TaskCommon< T >::suspend ( SuspensionType  suspensionType)

suspend the task given the suspension type

Suspends the task. Some implementations track if the suspension of a task was intentional or unintentional. The supplied suspensionType parameter indicates that this was intentional or unintentional. The type of suspension is also returned when calling isSuspended.

Parameters
suspensionTypeintentionality of the suspension

Friends And Related Function Documentation

◆ Os::Test::Task::Tester

template<typename T >
friend struct Os::Test::Task::Tester
friend

Definition at line 56 of file Task.hpp.


The documentation for this class was generated from the following file: