Embedded Multicore Building Blocks V1.0.0
Public Member Functions | List of all members
embb::mtapi::TaskContext Class Reference

Provides information about the status of the currently running Task. More...

#include <task_context.h>

Public Member Functions

 TaskContext (mtapi_task_context_t *task_context)
 Constructs a TaskContext from the given C representation. More...
 
bool ShouldCancel ()
 Queries whether the Task running in the TaskContext should finish. More...
 
mtapi_task_state_t GetTaskState ()
 Queries the current Task state. More...
 
mtapi_uint_t GetCurrentWorkerNumber ()
 Queries the index of the worker thread the Task is running on. More...
 
mtapi_uint_t GetInstanceNumber ()
 Queries the current instance of the currently executing Task. More...
 
mtapi_uint_t GetNumberOfInstances ()
 Queries the number of instances of the currently executing Task. More...
 
void SetStatus (mtapi_status_t error_code)
 Sets the return status of the running Task. More...
 
mtapi_task_context_t * GetInternal () const
 Returns the internal representation of this object. More...
 

Detailed Description

Provides information about the status of the currently running Task.

Constructor & Destructor Documentation

embb::mtapi::TaskContext::TaskContext ( mtapi_task_context_t *  task_context)
explicit

Constructs a TaskContext from the given C representation.

Concurrency
Thread-safe and wait-free
Parameters
task_contextThe C task context to wrap.

Member Function Documentation

bool embb::mtapi::TaskContext::ShouldCancel ( )

Queries whether the Task running in the TaskContext should finish.

Returns
true if the Task should finish, otherwise false
Concurrency
Not thread-safe
mtapi_task_state_t embb::mtapi::TaskContext::GetTaskState ( )

Queries the current Task state.

Returns
The current Task state.
Concurrency
Not thread-safe
mtapi_uint_t embb::mtapi::TaskContext::GetCurrentWorkerNumber ( )

Queries the index of the worker thread the Task is running on.

Returns
The worker thread index the Task is running on
Concurrency
Not thread-safe
mtapi_uint_t embb::mtapi::TaskContext::GetInstanceNumber ( )

Queries the current instance of the currently executing Task.

Returns
The current instance number
Concurrency
Not thread-safe
mtapi_uint_t embb::mtapi::TaskContext::GetNumberOfInstances ( )

Queries the number of instances of the currently executing Task.

Returns
The number of instances
Concurrency
Not thread-safe
void embb::mtapi::TaskContext::SetStatus ( mtapi_status_t  error_code)

Sets the return status of the running Task.

This will be returned by Task::Wait() and is set to MTAPI_SUCCESS by default.

Concurrency
Not thread-safe
Parameters
[in]error_codeThe status to return by Task::Wait(), Group::WaitAny(), Group::WaitAll()
mtapi_task_context_t* embb::mtapi::TaskContext::GetInternal ( ) const

Returns the internal representation of this object.

Allows for interoperability with the C interface.

Returns
A pointer to a mtapi_task_context_t.
Concurrency
Not thread-safe