RTOS Wrapper
API reference
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
BaseThreadsManager< EnumType, MaxCount > Class Template Reference

#include <BaseThreadsManager.h>

Public Member Functions

 BaseThreadsManager (const std::map< EnumType, BaseThread * > &threads, std::function< const char *(EnumType)> enumToStringFunc)
 
 BaseThreadsManager (const BaseThreadsManager &)=delete
 The Copy constructor is deleted to avoid copying instances.
 
BaseThreadsManager & operator= (const BaseThreadsManager &)=delete
 The assignment operator constructor is deleted to avoid copying instances.
 
virtual ~BaseThreadsManager ()
 
bool EnsureInitialized () noexcept
 Ensures that the BaseThreadsManager is initialized.
 
bool ResumeAll () noexcept
 
bool ResumeSelected (const std::vector< EnumType > &selectedEnums) noexcept
 
bool StartAll () noexcept
 
bool StartSelected (const std::vector< EnumType > &selectedEnums) noexcept
 
bool StartAllExceptSelected (const std::vector< EnumType > &selectedEnums) noexcept
 
bool StartAllAndWaitToVerify (uint32_t waitToVerifyTimeoutMsec) noexcept
 
bool StartSelectedAndWaitToVerify (const std::vector< EnumType > &selectedEnums, uint32_t waitToVerifyTimeoutMsec) noexcept
 
bool StartAllExceptSelectedAndWaitToVerify (const std::vector< EnumType > &selectedEnums, uint32_t waitToVerifyTimeoutMsec) noexcept
 
bool StopAll () noexcept
 
bool StopSelected (const std::vector< EnumType > &selectedEnums) noexcept
 
bool StopAllExceptSelected (const std::vector< EnumType > &selectedEnums) noexcept
 
bool StopAllAndWaitToVerify (uint32_t waitToVerifyTimeoutMsec) noexcept
 
bool StopSelectedAndWaitToVerify (const std::vector< EnumType > &selectedEnums, uint32_t waitToVerifyTimeoutMsec) noexcept
 
bool StopAllExceptSelectedAndWaitToVerify (const std::vector< EnumType > &selectedEnums, uint32_t waitToVerifyTimeoutMsec) noexcept
 
virtual bool PreThreadInitializationActions () noexcept
 
virtual bool PostThreadInitializationActions () noexcept
 

Private Member Functions

bool Initialize () noexcept
 Initializes the BaseThreadsManager.
 

Private Attributes

bool initialized
 
Mutex mutex
 
std::map< EnumType, BaseThread * > threadsManaged
 
std::function< const char *(EnumType)> enumToString
 
std::bitset< MaxCount > threadsInitializedTracker
 
std::bitset< MaxCount > threadsStartedTracker
 
std::bitset< MaxCount > threadsStoppedTracker
 

Static Private Attributes

static constexpr bool verbose = false
 
static constexpr bool timeBetweenChecksMsec = 10
 
static const char mutexName [] = "BaseThreadManager-Mutex"
 

Constructor & Destructor Documentation

◆ BaseThreadsManager() [1/2]

template<typename EnumType , EnumType MaxCount>
BaseThreadsManager< EnumType, MaxCount >::BaseThreadsManager ( const std::map< EnumType, BaseThread * > &  threads,
std::function< const char *(EnumType)>  enumToStringFunc 
)

No code at this time.

◆ BaseThreadsManager() [2/2]

template<typename EnumType , EnumType MaxCount>
BaseThreadsManager< EnumType, MaxCount >::BaseThreadsManager ( const BaseThreadsManager< EnumType, MaxCount > &  )
delete

The Copy constructor is deleted to avoid copying instances.

Returns
n/a

◆ ~BaseThreadsManager()

template<typename EnumType , EnumType MaxCount>
BaseThreadsManager< EnumType, MaxCount >::~BaseThreadsManager ( )
virtual

Member Function Documentation

◆ EnsureInitialized()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::EnsureInitialized ( )
noexcept

Ensures that the BaseThreadsManager is initialized.

This function checks if the BaseThreadsManager has been initialized and initializes it if not.

Returns
true if the BaseThreadsManager is initialized, false otherwise.

◆ Initialize()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::Initialize ( )
privatenoexcept

Initializes the BaseThreadsManager.

Returns
True if the initialization is successful, false otherwise.

If pre thread initialization actions fail, return false

If post thread initialization actions fail, return false

Otherwise, see if mutex and all threads managed are initialized.

◆ operator=()

template<typename EnumType , EnumType MaxCount>
BaseThreadsManager & BaseThreadsManager< EnumType, MaxCount >::operator= ( const BaseThreadsManager< EnumType, MaxCount > &  )
delete

The assignment operator constructor is deleted to avoid copying instances.

Returns
n/a

◆ PostThreadInitializationActions()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::PostThreadInitializationActions ( )
virtualnoexcept

◆ PreThreadInitializationActions()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::PreThreadInitializationActions ( )
virtualnoexcept

◆ ResumeAll()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::ResumeAll ( )
noexcept

◆ ResumeSelected()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::ResumeSelected ( const std::vector< EnumType > &  selectedEnums)
noexcept

◆ StartAll()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::StartAll ( )
noexcept

◆ StartAllAndWaitToVerify()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::StartAllAndWaitToVerify ( uint32_t  waitToVerifyTimeoutMsec)
noexcept

Function that will test if the thread has been started

Expecting true within the timeout specified

Print info to user.

Return result

◆ StartAllExceptSelected()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::StartAllExceptSelected ( const std::vector< EnumType > &  selectedEnums)
noexcept

Go through all threads managed

If it's not in the selected threads to not start

Start Thread

◆ StartAllExceptSelectedAndWaitToVerify()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::StartAllExceptSelectedAndWaitToVerify ( const std::vector< EnumType > &  selectedEnums,
uint32_t  waitToVerifyTimeoutMsec 
)
noexcept

For all threads managed

If they're not in the selected threads list indicated not to start

Start threads

Function that will test if the specified threads has been started

Get if the threads not selected are running

Check if all threads not selected have started

Expecting true within the timeout specified

Print info to user.

Return result

◆ StartSelected()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::StartSelected ( const std::vector< EnumType > &  selectedEnums)
noexcept

◆ StartSelectedAndWaitToVerify()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::StartSelectedAndWaitToVerify ( const std::vector< EnumType > &  selectedEnums,
uint32_t  waitToVerifyTimeoutMsec 
)
noexcept

Function that will test if the specified threads has been started

Get if the selected threads are running

Check if all specified subthreads have started

Expecting true within the timeout specified

Print info to user.

Return result

◆ StopAll()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::StopAll ( )
noexcept

◆ StopAllAndWaitToVerify()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::StopAllAndWaitToVerify ( uint32_t  waitToVerifyTimeoutMsec)
noexcept

Function that will test if the thread has been started

Expecting true within the timeout specified

◆ StopAllExceptSelected()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::StopAllExceptSelected ( const std::vector< EnumType > &  selectedEnums)
noexcept

◆ StopAllExceptSelectedAndWaitToVerify()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::StopAllExceptSelectedAndWaitToVerify ( const std::vector< EnumType > &  selectedEnums,
uint32_t  waitToVerifyTimeoutMsec 
)
noexcept

For all threads managed

If they're not in the selected threads list indicated not to start

Start threads

Function that will test if the specified threads has been stopped

Get if the threads not selected are stopped

Check if all threads not selected have started

Expecting true within the timeout specified

Print info to user.

Return result

◆ StopSelected()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::StopSelected ( const std::vector< EnumType > &  selectedEnums)
noexcept

◆ StopSelectedAndWaitToVerify()

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::StopSelectedAndWaitToVerify ( const std::vector< EnumType > &  selectedEnums,
uint32_t  waitToVerifyTimeoutMsec 
)
noexcept

Function that will test if the specified threads has been stopped

Expecting true within the timeout specified

Member Data Documentation

◆ enumToString

template<typename EnumType , EnumType MaxCount>
std::function<const char*(EnumType)> BaseThreadsManager< EnumType, MaxCount >::enumToString
private

◆ initialized

template<typename EnumType , EnumType MaxCount>
bool BaseThreadsManager< EnumType, MaxCount >::initialized
private

Flag indicating if the MwSubThreadsManager is initialized.

◆ mutex

template<typename EnumType , EnumType MaxCount>
Mutex BaseThreadsManager< EnumType, MaxCount >::mutex
private

◆ mutexName

template<typename EnumType , EnumType MaxCount>
const char BaseThreadsManager< EnumType, MaxCount >::mutexName = "BaseThreadManager-Mutex"
staticprivate

◆ threadsInitializedTracker

template<typename EnumType , EnumType MaxCount>
std::bitset<MaxCount> BaseThreadsManager< EnumType, MaxCount >::threadsInitializedTracker
private

◆ threadsManaged

template<typename EnumType , EnumType MaxCount>
std::map<EnumType, BaseThread*> BaseThreadsManager< EnumType, MaxCount >::threadsManaged
private

◆ threadsStartedTracker

template<typename EnumType , EnumType MaxCount>
std::bitset<MaxCount> BaseThreadsManager< EnumType, MaxCount >::threadsStartedTracker
private

◆ threadsStoppedTracker

template<typename EnumType , EnumType MaxCount>
std::bitset<MaxCount> BaseThreadsManager< EnumType, MaxCount >::threadsStoppedTracker
private

◆ timeBetweenChecksMsec

template<typename EnumType , EnumType MaxCount>
constexpr bool BaseThreadsManager< EnumType, MaxCount >::timeBetweenChecksMsec = 10
staticconstexprprivate

◆ verbose

template<typename EnumType , EnumType MaxCount>
constexpr bool BaseThreadsManager< EnumType, MaxCount >::verbose = false
staticconstexprprivate

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