ADTF  v2.14.3
cCyclicThread Class Reference

Cyclic thread that will call its thread function periodically. More...

Inheritance diagram for cCyclicThread:

Public Member Functions

 cCyclicThread ()
 Default constructor.
 
virtual ~cCyclicThread ()
 Destructor.
 
virtual tResult Create (const tThreadInfo *psThreadInfo)
 Creates the thread. More...
 
tResult Create (tVoid *pData=NULL, tSize szData=0, tUInt32 ui32Flags=0, IThreadFunc *pThreadFunc=NULL, tThreadEntrance fnThreadEntrance=NULL)
 Creates the thread. More...
 
virtual tVoid Release ()
 Releases all allocated resources and stops the thread. More...
 
tResult Run (tBool bWait=tFalse)
 Sets the thread state to running. More...
 
virtual tResult ThreadFunc ()
 Does the actual periodic calling of CycleFunc. More...
 
tResult SetCycleTime (tTimeStamp nCycleTime)
 Sets the cycle time. More...
 
- Public Member Functions inherited from cThread
const tThreadInfoGetThreadInfo () const
 Returns the thread info struct. More...
 
 cThread ()
 Default constructor.
 
virtual ~cThread ()
 Destructor.
 
tResult Run (tBool bWait=tFalse)
 Sets the thread state to running. More...
 
tResult Suspend (tBool bWait=tFalse)
 Sets the thread state to suspended. More...
 
tResult Reset (tBool bWait=tFalse)
 Resets/Restarts the thread (ThreadInitFunc etc. More...
 
tResult Terminate (tBool bWait=tFalse)
 Terminates the thread. More...
 
tBool IsCurrent () const
 Checks whether the thread is the calling thread. More...
 
tThreadState GetState () const
 Returns the current state of the thread. More...
 
tResult WaitForExit (tInt nTimeout=WAIT_Infinite)
 Blocks the calling thread until the thread has exited. More...
 
tResult SetPriority (tInt nPriority, tUInt32 ui32Flags=0)
 Set the scheduling priority of the thread. More...
 
tResult SetPostDestroyFunc (tPostDestroyFunc pFunc)
 The passed method will be called after this thread has been deleted, if it is self managed. More...
 
tResult SetProcessorAffinity (tUInt64 nMask)
 Set the CPU affinity of the thread. More...
 
tResult GetProcessorAffinity (tUInt64 *pnMask)
 Get the processor affinity of the thread. More...
 
tInt GetId () const
 Returns the system thread id of the current thread The thread id is guaranteed to be unique in the whole system. More...
 

Protected Member Functions

virtual tResult CyclicFunc ()
 This function will be called periodically. More...
 
- Protected Member Functions inherited from cThread
virtual tResult ThreadLoop ()
 This will will be called repeatedly by the default ThreadFunc while the Thread is in state running. More...
 
virtual tResult ThreadInitFunc ()
 This function will be called before the first call to ThreadLoop. More...
 
virtual tResult ThreadExitFunc ()
 This will be called after the last call to ThreadLoop. More...
 
tResult SetState (tThreadState ThreadState, tBool bWait=tFalse)
 Set current state of thread. More...
 
tResult EnableSelfManaged ()
 This can be used by a thread to turn itself into a self managed thread while it is running. More...
 

Additional Inherited Members

- Public Types inherited from cThread
enum  tThreadState { TS_New = 0, TS_Suspended = 1, TS_Running = 2, TS_Finished = 3 }
 Threadstate of the Thread. More...
 
enum  tThreadFlags { TF_None = 0x00, TF_Suspended = 0x01, TF_RealtimeScheduler = 0x02, TF_SelfManaged = 0x04 }
 The Thread Creation Flags. More...
 
enum  tThreadPriorities {
  TP_Undefined = 0x00, TP_Idle = 0x01, TP_BelowNormal = 0x02, TP_Normal = 0x03,
  TP_AboveNormal = 0x04, TP_High = 0x05, TP_Realtime = 0x06, TP_RealtimeMin = 0x0101,
  TP_RealtimeMax = TP_RealtimeMin + 98
}
 Thread Priorities. More...
 
typedef tResult(__STDCALLtThreadEntrance) (tVoid *pvUserData, tSize szUserData)
 Type of thread entry function.
 
typedef tVoid(* tPostDestroyFunc) ()
 Methods that can be passed as post destroy callback.
 
typedef tPostDestroyFunc tPostDestoryFunc
 Methods that can be passed as post destroy callback. More...
 
- Static Public Member Functions inherited from cThread
static tVoid Sleep (tTimeStamp tmMicroseconds)
 The calling thread will sleep for the specified amount of time. More...
 
static tVoid YieldExecution ()
 Gives the scheduler a chance to schedule another thread. More...
 
- Static Public Attributes inherited from cThread
static const tInt WAIT_Infinite = -1
 definition of wait infinite value
 

Detailed Description

Cyclic thread that will call its thread function periodically.

Important: Please think about using Kernel Timer functionality.which is provided from IKernel. The Kernel Timer has some advantages over cCyclicThread like regaining time if one call to the thread function takes longer than the defined interval and the speed is bound to the playback speed.

Definition at line 1093 of file thread.h.

Member Function Documentation

virtual tResult Create ( const tThreadInfo psThreadInfo)
virtual

Creates the thread.

Overrides cThread::Create.

Parameters
psThreadInfo[in] Creation info struct.
Return values
ERR_NOERRORif all went well.
ERR_POINTERif psThreadInfo is NULL
ERR_FAILEDif thread could not be created
ERR_NOT_SUPPORTED[Linux] if thread should be suspended with external thread loop

Reimplemented from cThread.

tResult Create ( tVoid pData = NULL,
tSize  szData = 0,
tUInt32  ui32Flags = 0,
IThreadFunc pThreadFunc = NULL,
tThreadEntrance  fnThreadEntrance = NULL 
)
virtual

Creates the thread.

Overrides cThread::Create.

Parameters
pData[in] User data that will be passed to the pThreadFunc or fnThreadEntrance.
szData[in] Size of the user data.
ui32Flags[in] See tThreadFlags
pThreadFunc[in] The IThreadFunc interface to use.
fnThreadEntrance[in] The thread entrance function to use, will override pThreadFunc.
Return values
ERR_NOERRORif all went well.
ERR_FAILEDif thread could not be created
ERR_NOT_SUPPORTED[Linux] if thread should be suspended with external thread loop

Reimplemented from cThread.

virtual tResult CyclicFunc ( )
protectedvirtual

This function will be called periodically.

Returns
No error if user did not provide own thread functions, otherwise result of said thread function.
Remarks
The implementation respects the time for running the CyclicFunc. It means the wait time between both CyclicFunc calls is nCycleTime - nTimeOfRunningYourImplementation
virtual tVoid Release ( )
virtual

Releases all allocated resources and stops the thread.

Overrides cThread::Create.

Returns
void

Reimplemented from cThread.

tResult Run ( tBool  bWait = tFalse)

Sets the thread state to running.

Parameters
bWait[in] Whether or not to wait for an acknowledgment.
Return values
ERR_NOERRORif all went well
ERR_NOT_INITIALISEDif thread was not yet initialized, e.g. Create was not called
ERR_NOT_SUPPORTEDif thread is in an state that cannot be suspended
ERR_UNEXPECTEDif thread could not be suspended for any other reason
tResult SetCycleTime ( tTimeStamp  nCycleTime)

Sets the cycle time.

Parameters
nCycleTime[in] The new cycle time. May be zero in order to call the threadfunc as fast as possible.
Return values
ERR_NOERRORif all went well.
ERR_INVAILD_ARGif cycle time is less then zero
virtual tResult ThreadFunc ( )
virtual

Does the actual periodic calling of CycleFunc.

Overrides cThread::ThreadFunc.

Returns
result of CyclicFunc cCyclicThread::CyclicFunc

Reimplemented from cThread.


Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Fri Mar 22 2019 by doxygen 1.8.10)