ADTF
IKernelabstract

Kernel interface for thread, timer and signal handling. More...

Inheritance diagram for IKernel:
[legend]

Classes

class  IKernelRunnable
 IObject based version of IRunnable. More...
 
class  IScheduling
 Interface for retrieving and setting of scheduling options. More...
 
class  ISignal
 Interface for a signal. More...
 
class  ISignalHandler
 Interface for signal handlers. More...
 
class  IThread
 Interface for a thread. More...
 
class  ITimer
 Interface for a timer. More...
 
struct  tSchedulingInfo
 Struct for defining scheduling settings of a thread or timer. More...
 

Public Types

enum class  tSchedulingClass : uint32_t { Default = 0 , Normal = 1 , RealTime = 2 }
 Enum for different scheduling schemes. More...
 
enum  tThreadFlags { THF_None = 0 , THF_Detached = 1 }
 Flags for thread creation. More...
 
enum class  tTimerClock : uint32_t { ADTF = 0 , Monotonic = 1 , RealTime = 2 }
 Enum for different time sources for timers. More...
 
enum  tTimerFlags : uint8_t {
  TIF_None = 0 , TIF_Reschedule = 1 , TIF_Drop = 2 , TIF_ErrorLog = 4 ,
  TIF_ErrorStop = 8
}
 Flags for time creation. More...
 
enum  tSignalFlags { SIG_None = 0 , SIG_Async = 1 }
 Enum for signal options. More...
 

Public Member Functions

 ADTF_IID (IKernel, "kernel.ant.services.adtf.iid")
 Interface ID for the kernel interface.
 
virtual tResult ThreadCreate (adtf::ucom::iobject_ptr< IThread > &pThread, const char *strThreadName, const adtf::ucom::iobject_ptr< IKernelRunnable > &pKernelRunnable, const void *pUserData=nullptr, size_t nUserDataSize=0, const tSchedulingInfo &sScheduling=tSchedulingInfo(), uint32_t ui32Flags=tThreadFlags::THF_None)=0
 Creates a new thread of execution that executes the Run method of the given runnable. More...
 
virtual tResult TimerCreate (adtf::ucom::iobject_ptr< ITimer > &pTimer, const char *strTimerName, tTimeStamp nPeriod, tTimeStamp nInitialDelay, const adtf::ucom::iobject_ptr< IKernelRunnable > &pKernelRunnable, const void *pUserData=nullptr, size_t nUserDataSize=0, tTimerClock eClock=tTimerClock::ADTF, const tSchedulingInfo &sScheduling=tSchedulingInfo(), uint32_t ui32Flags=tTimerFlags::TIF_None)=0
 Creates a new timer, that periodically calls the Run method of the given runnable. More...
 
virtual tResult SignalSend (const adtf::ucom::iobject_ptr< ISignal > &pSignal, uint32_t ui32Flags=tSignalFlags::SIG_None)=0
 Transmits a signal to all registered signal handlers. More...
 
virtual tResult SignalRegister (ISignalHandler &oHandler, uint32_t ui32Flags=tSignalFlags::SIG_None)=0
 Registers a new signal handler. More...
 
virtual tResult SignalUnregister (ISignalHandler &oHandler)=0
 Unregisters a signal handler. More...
 
virtual tResult GetObjects (adtf::ucom::iobject_enum< IObject > &oObjects)=0
 Returns a list of all kernel primitives. More...
 
- Public Member Functions inherited from IObject
 ADTF_IID (IObject, "object.ant.ucom.adtf.iid")
 Marks the IObject to be castable with the ucom_cast() More...
 

Protected Member Functions

 ~IKernel ()=default
 Protected destructor --> Use implemented Destroy() instead of delete!
 
- Protected Member Functions inherited from IObject
 ~IObject ()=default
 Protected destructor --> Use implemented Destroy() instead of delete!
 

Detailed Description

Kernel interface for thread, timer and signal handling.

Definition at line 25 of file kernel_intf.h.

Member Enumeration Documentation

◆ tSchedulingClass

enum tSchedulingClass : uint32_t
strong

Enum for different scheduling schemes.

Enumerator
Default 

The kernel may choose what it (or the user) likes.

Normal 

Basic non-realtime scheduling.

RealTime 

Realtime scheduling.

Definition at line 39 of file kernel_intf.h.

◆ tSignalFlags

Enum for signal options.

Enumerator
SIG_None 

No special behaviour.

SIG_Async 

Transmit signal asynchronously.

Definition at line 198 of file kernel_intf.h.

◆ tThreadFlags

Flags for thread creation.

Enumerator
THF_None 

No special behaviour.

THF_Detached 

Create a detached thread, the pThread handle is not set, so you cannot modify this thread after creation.

Definition at line 49 of file kernel_intf.h.

◆ tTimerClock

enum tTimerClock : uint32_t
strong

Enum for different time sources for timers.

Enumerator
ADTF 

ADTF Stream time.

Monotonic 

Realtime monotonic clock.

RealTime 

Realtime clock.

Definition at line 59 of file kernel_intf.h.

◆ tTimerFlags

enum tTimerFlags : uint8_t

Flags for time creation.

Enumerator
TIF_None 

No special behaviour.

TIF_Reschedule 

Reschedule timer interval in case of a missed start instant. Mutally exclusive with TIF_Drop. Default is to queue the timer calls.

TIF_Drop 

Drop missed timer calls and wait until the next valid point in time that matches the interval. Mutally exclusive with TIF_Reschedule. Default is to queue the timer calls.

TIF_ErrorLog 

Default error handling action for deadline and start instant misses is set to @adtf::base::elasto::IErrorHandling::tAction::Log.

TIF_ErrorStop 

Default error handling action for deadline and start instant misses is set to @adtf::base::elasto::IErrorHandling::tAction::Stop.

Definition at line 69 of file kernel_intf.h.

Member Function Documentation

◆ GetObjects()

virtual tResult GetObjects ( adtf::ucom::iobject_enum< IObject > &  oObjects)
pure virtual

Returns a list of all kernel primitives.

Parameters
[out]oObjectsPrimitives are stored in this container.
Returns
Standard result.

◆ SignalRegister()

virtual tResult SignalRegister ( ISignalHandler oHandler,
uint32_t  ui32Flags = tSignalFlags::SIG_None 
)
pure virtual

Registers a new signal handler.

Parameters
[in]oHandlerThe handler.
[in]ui32FlagsFlags, see tSignalFlags.
Returns
Standard result.

◆ SignalSend()

virtual tResult SignalSend ( const adtf::ucom::iobject_ptr< ISignal > &  pSignal,
uint32_t  ui32Flags = tSignalFlags::SIG_None 
)
pure virtual

Transmits a signal to all registered signal handlers.

Parameters
[in]pSignalThe signal.
[in]ui32FlagsFlags, see tSignalFlags.
Return values
ERR_CANCELEDa signal handler has canceled the processing of the signal.

◆ SignalUnregister()

virtual tResult SignalUnregister ( ISignalHandler oHandler)
pure virtual

Unregisters a signal handler.

Parameters
[in]oHandlerThe handler.
Returns
Standard result.

◆ ThreadCreate()

virtual tResult ThreadCreate ( adtf::ucom::iobject_ptr< IThread > &  pThread,
const char *  strThreadName,
const adtf::ucom::iobject_ptr< IKernelRunnable > &  pKernelRunnable,
const void *  pUserData = nullptr,
size_t  nUserDataSize = 0,
const tSchedulingInfo sScheduling = tSchedulingInfo(),
uint32_t  ui32Flags = tThreadFlags::THF_None 
)
pure virtual

Creates a new thread of execution that executes the Run method of the given runnable.

method. Please take a look at the adtf::system::kernel_thread template class, which transparently wraps this interface.

Parameters
[out]pThreadThis will be updated with a pointer to the interface of the created thread.
[in]strThreadNameThe name of the thread. Has to be unique among all registered kernel primitives.
[in]pKernelRunnableThe runnable that will be called.
[in]pUserDataThis is passed on to the runnable. Mind that the data is not stored or copied in any way, so make sure the pointer stays valid long enough.
[in]nUserDataSizeThe size of the user data passed to the runnable.
[in]sSchedulingThe scheduling settings.
[in]ui32FlagsThread flags, see tThreadFlags.
Return values
ERR_FAILEDThe scheduling settings are not valid.
ERR_RESOURCE_IN_USEThe given name is already used by another kernel primitive.

◆ TimerCreate()

virtual tResult TimerCreate ( adtf::ucom::iobject_ptr< ITimer > &  pTimer,
const char *  strTimerName,
tTimeStamp  nPeriod,
tTimeStamp  nInitialDelay,
const adtf::ucom::iobject_ptr< IKernelRunnable > &  pKernelRunnable,
const void *  pUserData = nullptr,
size_t  nUserDataSize = 0,
tTimerClock  eClock = tTimerClock::ADTF,
const tSchedulingInfo sScheduling = tSchedulingInfo(),
uint32_t  ui32Flags = tTimerFlags::TIF_None 
)
pure virtual

Creates a new timer, that periodically calls the Run method of the given runnable.

Please take a look at the adtf::system::kernel_timer template class, which transparently wraps this interface.

Parameters
[out]pTimerThis will be updated with a pointer to the interface of the created thread.
[in]strTimerNameThe name of the timer. Has to be unique among all registered kernel primitives.
[in]nPeriodThe period of the timer in microseconds. 0 = one-shot timer.
[in]nInitialDelayThe intial delay before the timer expires the first time.
[in]pKernelRunnableThe runnable that will be called.
[in]pUserDataThis is passed on to the runnable. Mind that the data is not stored or copied in any way, so make sure the pointer stays valid long enough.
[in]nUserDataSizeThe size of the user data passed to the runnable.
[in]eClockThe time source used by the timer.
[in]sSchedulingThe scheduling settings.
[in]ui32FlagsThread flags, see tTimerFlags.
Return values
ERR_FAILEDThe scheduling settings are not valid.
ERR_RESOURCE_IN_USEThe given name is already used by another kernel primitive.