fesa-core  5.0.1
fesa::MultiThreadedEventSource Class Reference

#include <MultiThreadedEventSource.h>

Inheritance diagram for fesa::MultiThreadedEventSource:
fesa::AbstractEventSource fesa::Thread fesa::HasMetrics fesa::OnSubscriptionEventSource

Public Member Functions

 MultiThreadedEventSource (std::size_t queueSize, const std::string &eventSourceName, const std::string &className, const boost::shared_ptr< Diagnostics > &diagnostics)
 
 MultiThreadedEventSource (std::size_t queueSize, const std::string &eventSourceName, EventSourceType sourceType, const std::string &className, const boost::shared_ptr< Diagnostics > &diagnostics)
 
virtual void disable ()
 
virtual void enable ()
 
void addEventProducer (MultiThreadedEventSourceProducer *producer)
 Adds a producer to this event source. This object takes ownership of the producer parameter and will delete it upon destruction. If this event source is enabled, the producer is started right away. Otherwise it will be started when this event source is enabled again. More...
 
- Public Member Functions inherited from fesa::AbstractEventSource
bool isEnabled () const
 Check if the source is enabled.
 
void printConfig (FesaStream *fesaStream) const
 Print the event source configuration. More...
 
void printState (std::ostream &stream, double elapsedTime) const
 Print the event source state. More...
 
virtual ~AbstractEventSource ()
 Destructor.
 
const std::string & getName () const
 Retrieve the name of the event source. More...
 
EventSourceType getType () const
 Retrieve the type of the event source. More...
 
uint32_t getEvtSrcPriority () const
 Retrieve the priority of the thread in which the event source runs. More...
 
uint32_t getEvtSrcID () const
 Retrieve the event source's thread ID. More...
 
- 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::AbstractEventSource
 AbstractEventSource (const std::string &eventSourceName, EventSourceType type, const std::string &className, const boost::shared_ptr< Diagnostics > &diagnostics)
 Constructor. More...
 
void run ()
 In a continuous loop, the source will wait for new events, and post them to the scheduler whenever they occur. All exceptions from underlying methods will be cought and logged at this level. This method is blocking.
 
virtual void addEvent (const boost::shared_ptr< fesa::EventElement > &eventElement, const boost::shared_ptr< LogicalEvent > &logicalEvent)
 Add an event to the event map of this source. More...
 
virtual void wait (boost::shared_ptr< RTEvent > &eventToFire)=0
 This method has to be overridden by the concrete event source in order to fire the RTEvent This method is blocking. More...
 
virtual void connect (const boost::shared_ptr< fesa::EventElement > &eventElement)=0
 Connect will be triggered, whenever a new concrete event was added to the event map. It is up to each derived event source to perform the right actions.
 
- 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::AbstractEventSource
DiagnosticsDefs::DiagStateCounter firedEventCount_
 number of event fired by this event-source.
 
- 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

This class inherits AbstractEventSource to provide multiple producers for a single event source. Each producer is a thread which gets the priority of this event source.

Constructor & Destructor Documentation

fesa::MultiThreadedEventSource::MultiThreadedEventSource ( std::size_t  queueSize,
const std::string &  eventSourceName,
const std::string &  className,
const boost::shared_ptr< Diagnostics > &  diagnostics 
)
Parameters
queueSizethe size of the events queue
eventSourceNamethe name of this event source
classNamethe class this event source belongs to
diagnosticsthe diagnostics object
fesa::MultiThreadedEventSource::MultiThreadedEventSource ( std::size_t  queueSize,
const std::string &  eventSourceName,
EventSourceType  sourceType,
const std::string &  className,
const boost::shared_ptr< Diagnostics > &  diagnostics 
)
Parameters
queueSizethe size of the events queue
eventSourceNamethe name of this event source
eventSourceTypetype of this event source
classNamethe class this event source belongs to
diagnosticsthe diagnostics object

Member Function Documentation

void fesa::MultiThreadedEventSource::addEventProducer ( MultiThreadedEventSourceProducer producer)

Adds a producer to this event source. This object takes ownership of the producer parameter and will delete it upon destruction. If this event source is enabled, the producer is started right away. Otherwise it will be started when this event source is enabled again.

Parameters
theproducer to add
void fesa::MultiThreadedEventSource::disable ( )
virtual

Disables this event source: every producer is disabled.

Reimplemented from fesa::AbstractEventSource.

void fesa::MultiThreadedEventSource::enable ( )
virtual

Enables this event source: every producer is enabled.

Reimplemented from fesa::AbstractEventSource.


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