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

Describes the execution policy of a parallel algorithm. More...

#include <execution_policy.h>

Public Member Functions

 ExecutionPolicy ()
 Constructs the default execution policy. More...
 
 ExecutionPolicy (bool initial_affinity, mtapi_uint_t priority)
 Constructs an execution policy with the specified affinity and priority. More...
 
 ExecutionPolicy (mtapi_uint_t priority)
 Constructs an execution policy with the specified priority. More...
 
 ExecutionPolicy (bool initial_affinity)
 Constructs an execution policy with the specified affinity. More...
 
void AddWorker (mtapi_uint_t worker)
 Sets affinity to a specific worker thread. More...
 
void RemoveWorker (mtapi_uint_t worker)
 Removes affinity to a specific worker thread. More...
 
bool IsSetWorker (mtapi_uint_t worker)
 Checks if affinity to a specific worker thread is set. More...
 
unsigned int GetCoreCount () const
 Returns the number of cores the policy is affine to. More...
 
mtapi_affinity_t GetAffinity () const
 Returns the affinity. More...
 
mtapi_uint_t GetPriority () const
 Returns the priority. More...
 

Detailed Description

Describes the execution policy of a parallel algorithm.

The execution policy comprises

The priority is a number between 0 (denoting the highest priority) to max_priorities - 1 as given during initialization using Node::Initialize(). The default value of max_priorities is 4.

Constructor & Destructor Documentation

embb::mtapi::ExecutionPolicy::ExecutionPolicy ( )

Constructs the default execution policy.

Sets the affinity to all worker threads and the priority to the default value.

Concurrency
Not thread-safe
embb::mtapi::ExecutionPolicy::ExecutionPolicy ( bool  initial_affinity,
mtapi_uint_t  priority 
)

Constructs an execution policy with the specified affinity and priority.

Concurrency
Not thread-safe
Parameters
[in]initial_affinitytrue sets the affinity to all worker threads, false to no worker threads.
[in]priorityPriority for the execution policy.
embb::mtapi::ExecutionPolicy::ExecutionPolicy ( mtapi_uint_t  priority)
explicit

Constructs an execution policy with the specified priority.

Sets the affinity to all worker threads.

Concurrency
Not thread-safe
Parameters
[in]priorityPriority for the execution policy.
embb::mtapi::ExecutionPolicy::ExecutionPolicy ( bool  initial_affinity)
explicit

Constructs an execution policy with the specified affinity.

Sets the priority to the default value.

Concurrency
Not thread-safe
Parameters
[in]initial_affinitytrue sets the affinity to all worker threads, false to no worker threads.

Member Function Documentation

void embb::mtapi::ExecutionPolicy::AddWorker ( mtapi_uint_t  worker)

Sets affinity to a specific worker thread.

Concurrency
Not thread-safe
Parameters
[in]workerWorker thread index
void embb::mtapi::ExecutionPolicy::RemoveWorker ( mtapi_uint_t  worker)

Removes affinity to a specific worker thread.

Concurrency
Not thread-safe
Parameters
[in]workerWorker thread index
bool embb::mtapi::ExecutionPolicy::IsSetWorker ( mtapi_uint_t  worker)

Checks if affinity to a specific worker thread is set.

Returns
true if affinity is set, otherwise false
Concurrency
Thread-safe and wait-free
Parameters
[in]workerWorker thread index
unsigned int embb::mtapi::ExecutionPolicy::GetCoreCount ( ) const

Returns the number of cores the policy is affine to.

Returns
the number of cores
Concurrency
Thread-safe and wait-free
mtapi_affinity_t embb::mtapi::ExecutionPolicy::GetAffinity ( ) const

Returns the affinity.

Returns
the affinity
Concurrency
Thread-safe and wait-free
mtapi_uint_t embb::mtapi::ExecutionPolicy::GetPriority ( ) const

Returns the priority.

Returns
the priority
Concurrency
Thread-safe and wait-free