ADTF  3.18.2
cKernelThreadLoopabstract

The Kernel Thread Loop class provides a thread that repeatedly calls the LoopFunc method. More...

Public Types

using tLoopState = adtf_util::cLooper::tLoopState
 

Public Member Functions

virtual ~cKernelThreadLoop ()
 Destructor.
 
tResult Create (const char *strName, const adtf::services::IKernel::tSchedulingInfo &sScheduling=adtf::services::IKernel::tSchedulingInfo(), bool bSelfDestruct=false, tLoopState eInitialState=tLoopState::Running)
 Creates the thread that executes the LoopFunc method. More...
 
tResult Release ()
 Destroys the thread. More...
 
tLoopState GetState ()
 Retrieves the current state of the looper. More...
 
tResult SetState (tLoopState eState, bool bWaitForAck=true)
 Changes the state of the internal looper. More...
 

Protected Member Functions

virtual tResult LoopFunc ()=0
 Implement this method. More...
 

Private Member Functions

void Loop ()
 
void SelfDestruct ()
 

Private Attributes

kernel_thread_looper m_oLooper
 
bool m_bSelfDestruct
 

Detailed Description

The Kernel Thread Loop class provides a thread that repeatedly calls the LoopFunc method.

You can change the state of the loop from within the LoopFunc as well.

Definition at line 60 of file kernel_thread_loop.h.

Member Function Documentation

◆ Create()

tResult Create ( const char *  strName,
const adtf::services::IKernel::tSchedulingInfo sScheduling = adtf::services::IKernel::tSchedulingInfo(),
bool  bSelfDestruct = false,
tLoopState  eInitialState = tLoopState::Running 
)

Creates the thread that executes the LoopFunc method.

Parameters
[in]strNameThe name of the thread.
[in]sSchedulingThe scheduling to use.
[in]bSelfDestructIf true, then the thread will release all its resources once the LoopFunc returns an error. Do not call any other methods of the current object after this call!
[in]eInitialStateThe initial state of the internal looper A_UTILS_NS::cLooper.
Returns
Standard result.

◆ GetState()

tLoopState GetState ( )

Retrieves the current state of the looper.

Returns
the current state of the looper.

◆ LoopFunc()

virtual tResult LoopFunc ( )
protectedpure virtual

Implement this method.

Returns
Any error will stop the looper, but the thread will still be alive and wait for state changes.

◆ Release()

tResult Release ( )

Destroys the thread.

Keep in mind that this blocks until LoopFunc returns.

Returns
Standard result.

◆ SetState()

tResult SetState ( tLoopState  eState,
bool  bWaitForAck = true 
)

Changes the state of the internal looper.

Parameters
[in]eStateThe new state.
[in]bWaitForAckIf true, wait until the thread aknowledges the change.
Returns
Standard result.