Embedded Multicore Building Blocks V1.0.0
Public Member Functions | Static Public Member Functions | List of all members
embb::base::CoreSet Class Reference

Represents a set of processor cores, used to set thread-to-core affinities. More...

#include <core_set.h>

Public Member Functions

 CoreSet ()
 Constructs an empty core set. More...
 
 CoreSet (bool value)
 Constructs a core set with all or no cores. More...
 
 CoreSet (const CoreSet &to_copy)
 Constructs a copy of the specified core set. More...
 
CoreSetoperator= (const CoreSet &to_assign)
 Assigns an existing core set. More...
 
void Reset (bool value)
 Resets the core set according to the specified value. More...
 
void Add (unsigned int core)
 Adds one core to the core set. More...
 
void Remove (unsigned int core)
 Removes one core from the core set. More...
 
bool IsContained (unsigned int core) const
 Checks whether the specified core is included in the set. More...
 
unsigned int Count () const
 Counts the number of cores in the set. More...
 
CoreSet operator& (const CoreSet &rhs) const
 Intersects this core set with the specified one. More...
 
CoreSet operator| (const CoreSet &rhs) const
 Unites this core set with the specified one. More...
 
CoreSetoperator&= (const CoreSet &rhs)
 Intersects this core set with the specified one and overwrites this core set. More...
 
CoreSetoperator|= (const CoreSet &rhs)
 Unites this core set with the specified one an overwrites this core set. More...
 
embb_core_set_t const & GetInternal () const
 Provides access to internal representation to use it with C API. More...
 

Static Public Member Functions

static unsigned int CountAvailable ()
 Returns the number of available processor cores. More...
 

Detailed Description

Represents a set of processor cores, used to set thread-to-core affinities.

An instance of this type represents a subset of processor cores. Core sets can be used to set thread-to-core affinities. A core in a core set might just represent a logical core (hyper-thread), depending on the underlying hardware. Each core is identified by a unique integer starting with 0. For example, the cores of a quad-core system are represented by the set {0,1,2,3}.

This class is essentially a wrapper for the underlying C implementation.

Concurrency
Not thread-safe

Constructor & Destructor Documentation

embb::base::CoreSet::CoreSet ( )

Constructs an empty core set.

embb::base::CoreSet::CoreSet ( bool  value)
explicit

Constructs a core set with all or no cores.

Parameters
[in]valuetrue includes all cores in the set, false excludes all
embb::base::CoreSet::CoreSet ( const CoreSet to_copy)

Constructs a copy of the specified core set.

Parameters
[in]to_copyCore set to copy

Member Function Documentation

static unsigned int embb::base::CoreSet::CountAvailable ( )
static

Returns the number of available processor cores.

If the processor supports hyper-threading, each hyper-thread is treated as a separate processor core.

Returns
Number of cores including hyper-threads
CoreSet& embb::base::CoreSet::operator= ( const CoreSet to_assign)

Assigns an existing core set.

Returns
Reference to *this
Parameters
[in]to_assignCore set to assign
void embb::base::CoreSet::Reset ( bool  value)

Resets the core set according to the specified value.

Parameters
[in]valuetrue includes all cores in the set, false excludes all
void embb::base::CoreSet::Add ( unsigned int  core)

Adds one core to the core set.

Parameters
[in]coreCore to add (from 0 to number of cores - 1)
void embb::base::CoreSet::Remove ( unsigned int  core)

Removes one core from the core set.

Parameters
[in]coreCore to remove (from 0 to number of cores - 1)
bool embb::base::CoreSet::IsContained ( unsigned int  core) const

Checks whether the specified core is included in the set.

Returns
true if core is included, otherwise false
Parameters
[in]coreCore to check (from 0 to number of cores - 1)
unsigned int embb::base::CoreSet::Count ( ) const

Counts the number of cores in the set.

Returns
Number of cores in the set
CoreSet embb::base::CoreSet::operator& ( const CoreSet rhs) const

Intersects this core set with the specified one.

This core set is not modified by the operation.

Returns
Copy of the result
Parameters
[in]rhsCore set on right-hand side of intersection operation
CoreSet embb::base::CoreSet::operator| ( const CoreSet rhs) const

Unites this core set with the specified one.

This core set is not modified by the operation.

Returns
Copy of the result
Parameters
[in]rhsCore set on right-hand side of union operation
CoreSet& embb::base::CoreSet::operator&= ( const CoreSet rhs)

Intersects this core set with the specified one and overwrites this core set.

Returns
Reference to *this
Parameters
[in]rhsCore set on right-hand side of intersection operation
CoreSet& embb::base::CoreSet::operator|= ( const CoreSet rhs)

Unites this core set with the specified one an overwrites this core set.

Returns
Reference to *this
Parameters
[in]rhsCore set on right-hand side of union operation
embb_core_set_t const& embb::base::CoreSet::GetInternal ( ) const

Provides access to internal representation to use it with C API.

Returns
A reference to the internal embb_core_set_t structure.