#include <mn_foreign_task.hpp>

+ Inheritance diagram for mn::ext::foreign_task:
+ Collaboration diagram for mn::ext::foreign_task:

Public Member Functions

int start (int uiCore=-1)
 
- Public Member Functions inherited from mn::basic_task
 basic_task () noexcept
 
 basic_task (std::string strName, basic_task::priority uiPriority=basic_task::priority::Normal, unsigned short usStackDepth=MN_THREAD_CONFIG_MINIMAL_STACK_SIZE) noexcept
 
virtual ~basic_task ()
 Our destructor. Delete the task. More...
 
int kill ()
 Destroy and delete the task and call the function 'on_kill'. More...
 
bool is_running ()
 Is the Task running? More...
 
std::string get_name ()
 Get the debug name of this task. More...
 
basic_task::priority get_priority ()
 Get the priority of this task. More...
 
unsigned short get_stackdepth ()
 Get the stack depth of this task. More...
 
xTaskHandle get_handle ()
 Accessor to get the task's backing task handle. There is no setter, on purpose. More...
 
int get_return_value ()
 Get the return value of this task - after run. More...
 
timespan_t get_time_since_start () const
 Get the time since start of this task. More...
 
int32_t get_id ()
 Get the FreeRTOS task Numberid of this task. More...
 
int32_t get_on_core ()
 Get the core number of this task run. More...
 
void set_priority (basic_task::priority uiPriority)
 Set the priority of this task. More...
 
void suspend ()
 Suspend this task. More...
 
void resume ()
 Resume a specific task. More...
 
bool joinable () const noexcept
 
int join (unsigned int xTickTimeout=portMAX_DELAY)
 join the task, Wait in other task to end this task. More...
 
int join (timespan_t time)
 join the task, Wait in other task to end this task. More...
 
int wait (unsigned int xTimeOut)
 Wait for start the task. More...
 
int wait (timespan_t time)
 Wait for start the task. More...
 
virtual void on_start ()
 This virtual function call on creating, use for user code It is optional whether you implement this or not. More...
 
virtual void on_kill ()
 This virtual function call on kill, use for user code It is optional whether you implement this or not. More...
 
virtual void on_cleanup ()
 Called on exit from your on_task() routine. More...
 
state get_state ()
 Get the state of the task. More...
 
 operator xTaskHandle ()
 Operator to get the task's backing task handle. More...
 
 operator int ()
 Operator to get the ID assigned to the task. More...
 
bool operator== (const basic_task &r) const
 
bool operator!= (const basic_task &r) const
 
bool operator< (const basic_task &r) const
 
bool operator> (const basic_task &r) const
 

Static Public Member Functions

static foreign_taskget_idle_task ()
 
static foreign_taskget_idle_task (UBaseType_t cpuid)
 
static foreign_taskcreate_from (void *foreign_handle, int *ret_error=nullptr)
 
- Static Public Member Functions inherited from mn::basic_task
static void suspend (basic_task *t)
 Suspend the given task. More...
 
static void resume (basic_task *t)
 Resume the given task. More...
 
static void yield ()
 Yield the scheduler. More...
 
static void sleep (unsigned int secs)
 sleep this task for n seconds More...
 
static void usleep (unsigned int usec)
 sleep this task for n micro seconds More...
 
static void nsleep (const timespan_t &req, timespan_t *rem)
 pause execution for a specified time More...
 
static uint32_t get_tasks ()
 Get current number of tasks. More...
 
static bool is_current (basic_task *task)
 Is the given task the current running task ? More...
 
static basic_taskget_self ()
 Get the current task. More...
 

Protected Member Functions

int on_task ()
 

Private Member Functions

 foreign_task ()
 
 foreign_task (void *t)
 
int create_usings_types ()
 

Additional Inherited Members

- Public Types inherited from mn::basic_task
enum class  priority {
  Idle = MN_THREAD_CONFIG_CORE_PRIORITY_IDLE , Low = MN_THREAD_CONFIG_CORE_PRIORITY_LOW , Normal = MN_THREAD_CONFIG_CORE_PRIORITY_NORM , HalfCritical = MN_THREAD_CONFIG_CORE_PRIORITY_HALFCRT ,
  Urgent = MN_THREAD_CONFIG_CORE_PRIORITY_URGENT , Critical = MN_THREAD_CONFIG_CORE_PRIORITY_CRITICAL
}
 Task priority. More...
 
enum class  state {
  Running = 0 , Ready , Blocked , Suspended ,
  Deleted
}
 
using native_handle_type = xTaskHandle
 
- Static Protected Member Functions inherited from mn::basic_task
static void runtaskstub (void *parm)
 Adapter function that allows you to write a class specific on_task() function that interfaces with FreeRTOS. More...
 
- Protected Attributes inherited from mn::basic_task
LockType_t m_runningMutex
 Lock Objekt for task safty. More...
 
LockType_t m_contextMutext
 
LockType_t m_continuemutex
 
std::string m_strName
 The name of this task. More...
 
basic_task::priority m_uiPriority
 A saved / cached copy of what the task's priority is. More...
 
unsigned short m_usStackDepth
 Stack depth of this task, in words. More...
 
int m_retval
 The return value from user task routine. More...
 
bool m_bRunning
 Flag whether or not the task was started. More...
 
int32_t m_iID
 The FreeRTOS task Number. More...
 
int32_t m_iCore
 A saved / cached copy of which core this task is running on. More...
 
native_handle_type m_pHandle
 Reference to the underlying task handle for this task. More...
 
event_group_t m_eventGroup
 

Detailed Description

Wrapper class around FreeRTOS's implementation of a task, for foreign miniThread Task

Note
using foreign_task::create_from to create all using LockObjects objects

Constructor & Destructor Documentation

◆ foreign_task() [1/2]

mn::ext::foreign_task::foreign_task ( )
private

Constructor - the current thread

◆ foreign_task() [2/2]

mn::ext::foreign_task::foreign_task ( void *  t)
private

Constructor - from a FreeRTOS handle

Member Function Documentation

◆ create_from()

foreign_task * mn::ext::foreign_task::create_from ( void *  foreign_handle,
int *  ret_error = nullptr 
)
static

Helper function to create a foreign_task from a FreeRTOS handle

Parameters
foreign_handleThe FreeRTOS handle
ret_erroroptional pointer for creating error code:
  • ERR_MNTHREAD_OUTOFMEM: Can not alloc a new foreign_task object, out of mem.
  • ERR_MNTHREAD_NULL: The given handle is null.
  • ERR_TASK_OK: No error.

◆ create_usings_types()

int mn::ext::foreign_task::create_usings_types ( )
private

Internal functions to create all usings locktypes its call from create_from

Returns
  • ERR_MNTHREAD_NULL: The hanle is null.
  • ERR_TASK_OK: No error.

◆ get_idle_task() [1/2]

foreign_task * mn::ext::foreign_task::get_idle_task ( )
static

Get the foreign_task of idle task for the current CPU.

Returns
The foreign_task of the idle task.

◆ get_idle_task() [2/2]

foreign_task * mn::ext::foreign_task::get_idle_task ( UBaseType_t  cpuid)
static

Get the foreign_task of idle task for the given CPU.

Parameters
cpuidThe CPU to get the foreign_task for
Returns
Idle foreign_task of a given cpu.

◆ on_task()

int mn::ext::foreign_task::on_task ( )
inlineprotectedvirtual

Override - Do nothings and never call

Returns
ERR_TASK_OK

Reimplemented from mn::basic_task.

◆ start()

int mn::ext::foreign_task::start ( int  uiCore = -1)
inlinevirtual

Override - do nothings

Reimplemented from mn::basic_task.


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