RSB  0.19.0
rsb::eventprocessing::DirectEventReceivingStrategy Class Reference

This push-style event receiving strategy filters and dispatches rsb::Event s in the context of the thread calling handle. More...

#include <DirectEventReceivingStrategy.h>

Inheritance diagram for rsb::eventprocessing::DirectEventReceivingStrategy:
Inheritance graph
Collaboration diagram for rsb::eventprocessing::DirectEventReceivingStrategy:
Collaboration graph

Public Member Functions

 DirectEventReceivingStrategy (bool singleThreaded=false)
 
virtual ~DirectEventReceivingStrategy ()
 
void printContents (std::ostream &stream) const
 
void setHandlerErrorStrategy (const ParticipantConfig::ErrorStrategy &strategy)
 Defines the strategy to use for handling dispatching errors to the client handler. More...
 
virtual void addHandler (rsb::HandlerPtr handler, const bool &wait)
 Adds a new handler that will be notified about new events. More...
 
virtual void removeHandler (rsb::HandlerPtr handler, const bool &wait)
 Removes a handler that will will then not be notified anymore. More...
 
virtual void addFilter (filter::FilterPtr filter)
 
virtual void removeFilter (filter::FilterPtr filter)
 
void handle (EventPtr e)
 Dispatches the event to the listener. More...
 
- Public Member Functions inherited from rsb::eventprocessing::EventReceivingStrategy
virtual ~EventReceivingStrategy ()
 
- Public Member Functions inherited from rsb::eventprocessing::Handler
virtual ~Handler ()
 

Static Public Member Functions

static EventReceivingStrategycreate (const rsc::runtime::Properties &props)
 

Private Types

typedef std::list< rsb::HandlerPtrHandlerList
 

Private Member Functions

bool filter (EventPtr event)
 
void deliver (rsb::HandlerPtr handler, EventPtr event)
 
void handleDispatchError (const std::string &message)
 
bool filterNoLock (EventPtr e)
 
void handleNoLock (EventPtr e)
 

Private Attributes

rsc::logging::LoggerPtr logger
 
boost::shared_mutex filtersMutex
 
std::set< filter::FilterPtrfilters
 
boost::shared_mutex errorStrategyMutex
 
ParticipantConfig::ErrorStrategy errorStrategy
 
boost::shared_mutex handlerMutex
 
HandlerList handlers
 
bool singleThreaded
 

Detailed Description

This push-style event receiving strategy filters and dispatches rsb::Event s in the context of the thread calling handle.

Even calls to rsb::Handler s run in this thread, so stack exhaustion and deadlocks are possible.

Additionally, all locking can be disabled for situation in which it can be guaranteed that only one thread at a time calls any of the classes methods.

Author
jmoringe

Definition at line 61 of file DirectEventReceivingStrategy.h.

Member Typedef Documentation

Constructor & Destructor Documentation

rsb::eventprocessing::DirectEventReceivingStrategy::DirectEventReceivingStrategy ( bool  singleThreaded = false)

Definition at line 53 of file DirectEventReceivingStrategy.cpp.

rsb::eventprocessing::DirectEventReceivingStrategy::~DirectEventReceivingStrategy ( )
virtual

Definition at line 59 of file DirectEventReceivingStrategy.cpp.

Member Function Documentation

void rsb::eventprocessing::DirectEventReceivingStrategy::addFilter ( filter::FilterPtr  filter)
virtual
void rsb::eventprocessing::DirectEventReceivingStrategy::addHandler ( rsb::HandlerPtr  handler,
const bool &  wait 
)
virtual

Adds a new handler that will be notified about new events.

Parameters
handlerhandler to add
waitif set to true, this method must only return after the handler has been install completely so that the next event will be delivered to it

Implements rsb::eventprocessing::PushEventReceivingStrategy.

Definition at line 195 of file DirectEventReceivingStrategy.cpp.

References handlerMutex, and handlers.

EventReceivingStrategy * rsb::eventprocessing::DirectEventReceivingStrategy::create ( const rsc::runtime::Properties &  props)
static

Definition at line 49 of file DirectEventReceivingStrategy.cpp.

Referenced by rsb::eventprocessing::registerDefaultEventProcessingStrategies().

Here is the caller graph for this function:

void rsb::eventprocessing::DirectEventReceivingStrategy::deliver ( rsb::HandlerPtr  handler,
EventPtr  event 
)
private

Definition at line 143 of file DirectEventReceivingStrategy.cpp.

References handleDispatchError(), and logger.

Referenced by handleNoLock().

Here is the call graph for this function:

Here is the caller graph for this function:

bool rsb::eventprocessing::DirectEventReceivingStrategy::filter ( EventPtr  event)
private

Definition at line 76 of file DirectEventReceivingStrategy.cpp.

References filterNoLock(), filtersMutex, handleDispatchError(), and singleThreaded.

Referenced by handleNoLock().

Here is the call graph for this function:

Here is the caller graph for this function:

bool rsb::eventprocessing::DirectEventReceivingStrategy::filterNoLock ( EventPtr  e)
private

Definition at line 111 of file DirectEventReceivingStrategy.cpp.

References filters.

Referenced by filter().

Here is the caller graph for this function:

void rsb::eventprocessing::DirectEventReceivingStrategy::handle ( EventPtr  event)
virtual

Dispatches the event to the listener.

Parameters
eventthe event to dispatch

Implements rsb::eventprocessing::EventReceivingStrategy.

Definition at line 175 of file DirectEventReceivingStrategy.cpp.

References handleNoLock(), handlerMutex, and singleThreaded.

Here is the call graph for this function:

void rsb::eventprocessing::DirectEventReceivingStrategy::handleDispatchError ( const std::string &  message)
private
void rsb::eventprocessing::DirectEventReceivingStrategy::handleNoLock ( EventPtr  e)
private

Definition at line 185 of file DirectEventReceivingStrategy.cpp.

References deliver(), filter(), and handlers.

Referenced by handle().

Here is the call graph for this function:

Here is the caller graph for this function:

void rsb::eventprocessing::DirectEventReceivingStrategy::printContents ( std::ostream &  stream) const
void rsb::eventprocessing::DirectEventReceivingStrategy::removeFilter ( filter::FilterPtr  filter)
virtual
void rsb::eventprocessing::DirectEventReceivingStrategy::removeHandler ( rsb::HandlerPtr  handler,
const bool &  wait 
)
virtual

Removes a handler that will will then not be notified anymore.

Parameters
handlerhandler to remove
waitif set to true, this method must only return after the handler has been removed completely and will not receive any more notifications

Implements rsb::eventprocessing::PushEventReceivingStrategy.

Definition at line 202 of file DirectEventReceivingStrategy.cpp.

References handlerMutex, and handlers.

void rsb::eventprocessing::DirectEventReceivingStrategy::setHandlerErrorStrategy ( const ParticipantConfig::ErrorStrategy strategy)
virtual

Defines the strategy to use for handling dispatching errors to the client handler.

Parameters
strategythe new strategy to use

Implements rsb::eventprocessing::PushEventReceivingStrategy.

Definition at line 70 of file DirectEventReceivingStrategy.cpp.

References errorStrategy, and errorStrategyMutex.

Member Data Documentation

ParticipantConfig::ErrorStrategy rsb::eventprocessing::DirectEventReceivingStrategy::errorStrategy
private
boost::shared_mutex rsb::eventprocessing::DirectEventReceivingStrategy::errorStrategyMutex
mutableprivate
std::set<filter::FilterPtr> rsb::eventprocessing::DirectEventReceivingStrategy::filters
private
boost::shared_mutex rsb::eventprocessing::DirectEventReceivingStrategy::filtersMutex
mutableprivate

Definition at line 99 of file DirectEventReceivingStrategy.h.

Referenced by addFilter(), filter(), printContents(), and removeFilter().

boost::shared_mutex rsb::eventprocessing::DirectEventReceivingStrategy::handlerMutex
mutableprivate

Definition at line 105 of file DirectEventReceivingStrategy.h.

Referenced by addHandler(), handle(), and removeHandler().

HandlerList rsb::eventprocessing::DirectEventReceivingStrategy::handlers
private

Definition at line 106 of file DirectEventReceivingStrategy.h.

Referenced by addHandler(), handleNoLock(), and removeHandler().

rsc::logging::LoggerPtr rsb::eventprocessing::DirectEventReceivingStrategy::logger
private

Definition at line 97 of file DirectEventReceivingStrategy.h.

Referenced by deliver(), and handleDispatchError().

bool rsb::eventprocessing::DirectEventReceivingStrategy::singleThreaded
private

Definition at line 108 of file DirectEventReceivingStrategy.h.

Referenced by filter(), handle(), and printContents().


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