fesa-core  5.0.1
fesa::RTScheduler Class Reference

The scheduler class contains the real time behavior of the class. It waits for events and then executes the real time action related to them. More...

#include <RTScheduler.h>

Inheritance diagram for fesa::RTScheduler:
fesa::Thread fesa::HasMetrics

Public Member Functions

 RTScheduler (const std::string &name, int32_t eventQueueSize, EventDiscardPolicy::EventDiscardPolicy eventDiscardPolicy, bool errorOnEventDiscard, const ThreadConfigurer::SchedulingConfig &threadSchedulingConfig)
 
 RTScheduler ()
 Empty Constructor, used for unit-testing (Mocking of this class)
 
virtual ~RTScheduler ()
 
virtual void post (uint32_t logicalEventID, boost::shared_ptr< RTEvent > &concreteEvent, AtomicSizeTPtr &nSchedulers)
 This method inserts the event passed by argument into the queue of the scheduler in order to process it. More...
 
void updateAcquisitionTimestamp (timestamp_ns timestamp, AtomicSizeTPtr &nSchedulers)
 
virtual void addRTAction (uint32_t logicalEventID, AbstractRTAction *rtAction)
 This method links the RT action and the event passed by arguments. More...
 
virtual const std::string & getName () const
 return the name of this RTScheduler
 
virtual void printState (std::ostream &stream, double elapsedTime)
 Print some information about the actual state of the RTScheduler. More...
 
virtual void printConfig (FesaStream *fesaStream)
 
virtual void cancel ()
 This call provokes the stop of the scheduler and an exit on the current thread.
 
- Public Member Functions inherited from fesa::Thread
 Thread ()
 Constructor. More...
 
virtual ~Thread ()
 Destructor.
 
void setDetachState (int32_t state)
 Modify the detach state of the thread. More...
 
void start (bool blockingMode, const std::string &threadName, bool permanent=true)
 
virtual void stop ()
 Stop the thread.
 
int join (void **status)
 
bool isRunning () const
 Check if the thread is running. More...
 
pthread_t getID () const
 Get the process ID. More...
 
int32_t getPriority () const
 Get the priority of the thread. More...
 
cpu_set_t getAffinity () const
 Get the affinity of the thread.
 
void setPriority (int32_t priority)
 Set the priority of the thread. More...
 
void setAffinity (cpu_set_t affinity)
 Set the affinity of the thread. More...
 
- Public Member Functions inherited from fesa::HasMetrics
 HasMetrics (const std::string &componentName)
 

Additional Inherited Members

- Static Public Member Functions inherited from fesa::Thread
static void AdjustProcessScheduling ()
 The process priority can only be adjusted in the main thread. It needs to be adjusted to the maximal thread priority since it sets the limit of the thread priorities of this process. More...
 
static std::string getThreadName (pthread_t threadId)
 Get the name of the thread by its id. More...
 
static std::string getCurrentThreadName ()
 
static void registerThreadIdName (pthread_t threadId, const std::string &threadName)
 Associate a thread id with a name. More...
 
static void registerThreadId (pthread_t threadId, Thread *thread)
 Associate a thread id with a name. More...
 
static Threadcurrent ()
 Returns the Thread object associated with the current thread.
 
static ThreadgetById (pthread_t id)
 Returns the Thread object associated with the given id. Throws FesaException if the id is unknown. More...
 
static const std::set< const
Thread * > 
getThreads ()
 
- Protected Member Functions inherited from fesa::HasMetrics
template<typename T >
void registerMetric (const std::string &name, T &value)
 
template<typename T >
void registerMetric (const std::string &name, boost::atomic< T > &value)
 
- Protected Attributes inherited from fesa::Thread
bool isRunning_
 true if the thread is running
 
bool hasFinished_
 true if the thread has finished.
 
bool joinHasFinished_
 if true, a call to pthread_join has completed and a further pthread_cancel / pthread_join call is unsafe
 
bool permanent_
 
pthread_t tid_
 Id of this thread.
 

Detailed Description

The scheduler class contains the real time behavior of the class. It waits for events and then executes the real time action related to them.

Constructor & Destructor Documentation

fesa::RTScheduler::RTScheduler ( const std::string &  name,
int32_t  eventQueueSize,
EventDiscardPolicy::EventDiscardPolicy  eventDiscardPolicy,
bool  errorOnEventDiscard,
const ThreadConfigurer::SchedulingConfig threadSchedulingConfig 
)
Parameters
namename of the scheduler
eventQueueSizeevent queue size
eventDiscardPolicyevent discard policy to use
errorOnEventDiscardif true, an error is logged when an event is discarded
priothe priority of this scheduler
fesa::RTScheduler::~RTScheduler ( )
virtual

Destructor

Member Function Documentation

void fesa::RTScheduler::addRTAction ( uint32_t  logicalEventID,
AbstractRTAction rtAction 
)
virtual

This method links the RT action and the event passed by arguments.

Parameters
logicalEventIDID of the logical-event which fires the action
rtActionto be executed when the event arrives
void fesa::RTScheduler::post ( uint32_t  logicalEventID,
boost::shared_ptr< RTEvent > &  concreteEvent,
AtomicSizeTPtr &  nSchedulers 
)
virtual

This method inserts the event passed by argument into the queue of the scheduler in order to process it.

Parameters
logicalEventIDID of the logical event which is associated to the passed concrete event
concreteEventconcrete event which should be processed by this scheduler
nSchedulersnumber of schedulers scheduling this event
void fesa::RTScheduler::printConfig ( FesaStream *  fesaStream)
virtual
Parameters
fesaStream
void fesa::RTScheduler::printState ( std::ostream &  stream,
double  elapsedTime 
)
virtual

Print some information about the actual state of the RTScheduler.

Parameters
fesaStream
elapsedTime
void fesa::RTScheduler::updateAcquisitionTimestamp ( timestamp_ns  timestamp,
AtomicSizeTPtr &  nSchedulers 
)

Updates the latest acquisition timestamp if nSchedulers reaches 0 after being decremented.

Parameters
nSchedulersnumber of schedulers still scheduling the current event
timestampvalue of the new acquisition timestamp

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