EventProcessor Class Reference
[Event Interface.Execution Engine]

#include <rtt/EventProcessor.hpp>

Inheritance diagram for EventProcessor:

RunnableInterface BlockingEventProcessor CompletionProcessor

List of all members.


Detailed Description

An Asynchronous Event Processor, which catches events and executes the asynchronous callbacks in its RunnableInterface::step().

This class is mostly used internally by Orocos, but users can use it to process asynchronous callbacks in their own implementation. The EventProcessor is an argument in the Event's asynchronous connect method.

Changing the Event Processing Policy.
The default policy of the EventProcessor is to process all asynchronous callbacks in step(). In order to change the processing of the asynchronous events, subclass this class and override step() or other virtual functions. The BlockingEventProcessor is an example of an EventProcessor with a different policy, and can be subclassed in turn.

See also:
CompletionProcessor

Definition at line 476 of file EventProcessor.hpp.


Public Types

enum  AsynStorageType { OnlyFirst, OnlyLast }
 For Asynchronous callbacks, this enum defines how the arguments are stored in case of an overrun, ie, when the event is fired multiple times, before the asynchronous callback can be called. More...

Public Member Functions

 EventProcessor ()
 Create a periodic EventProcessor.
 ~EventProcessor ()
bool initialize ()
 The method that will be called before the first periodical execution of step() ( or non periodical execution of loop() ), when the thread is started.
void step ()
 The method that will be periodically executed when this class is run in a periodic thread.
void finalize ()
 The method that will be called after the last periodical execution of step() ( or non periodical execution of loop() ), when the RunnableInterface is stopped.
bool breakLoop ()
 Force the loop() method to return.
template<class SignalType>
Handle connect (const typename SignalType::SlotFunction &f, SignalType &sig, AsynStorageType t)
 Connect a function to an Event and process upon each event the function in this event processor.
template<class SignalType>
Handle setup (const typename SignalType::SlotFunction &f, SignalType &sig, AsynStorageType t)
 Setup the processing of an asynchronous event.
virtual void loop ()
 The method that will be executed once when this class is run in a non periodic thread.
ThreadInterfacegetThread () const
 Get the thread this object is run in.
virtual void setThread (ThreadInterface *t)
 Set the thread this object will be run in.

Protected Types

typedef ListLockFree
< detail::EventCatcher * > 
List
 The EC is released when the connection it is used in is deleted *and* it is removed from this vector.

Protected Member Functions

void destroyed (detail::EventCatcher *ec)

Protected Attributes

List catchers

Friends

class detail::EventCatcher

Member Enumeration Documentation

enum AsynStorageType

For Asynchronous callbacks, this enum defines how the arguments are stored in case of an overrun, ie, when the event is fired multiple times, before the asynchronous callback can be called.

Enumerator:
OnlyFirst 
OnlyLast  < Only call the callback once with the first fire() call's arguments

< Only call the callback once with the last fire() call's arguments

Definition at line 499 of file EventProcessor.hpp.


Member Function Documentation

Handle connect ( const typename SignalType::SlotFunction &  f,
SignalType &  sig,
AsynStorageType  t 
) [inline]

Connect a function to an Event and process upon each event the function in this event processor.

The returned handle holds the connection between f and sig.

Parameters:
f will be called within this EventProcessor when sig is emitted.
sig The Event to which f will react.
t specifies the policy in case of over-runs. That is, when sig is emitted multiple times before f could be called.
Returns:
An connected handle. Call Handle::disconnect() upon this object in order to remove the link between f and sig.

Definition at line 533 of file EventProcessor.hpp.

References Handle::connect(), and EventProcessor::setup().

Referenced by Event< void(void) >::connect().

Handle setup ( const typename SignalType::SlotFunction &  f,
SignalType &  sig,
AsynStorageType  t 
) [inline]

Setup the processing of an asynchronous event.

The returned handle does not yet connect f and sig. Use Handle::connect().

Parameters:
f will be called within this EventProcessor when sig is emitted.
sig The Event to which f will react.
t specifies the policy in case of over-runs. That is, when sig is emitted multiple times before f could be called.
Returns:
An unconnected handle. Call Handle::connect() upon this object in order to activate the link between f and sig.

Definition at line 551 of file EventProcessor.hpp.

References ListLockFree::append(), EventProcessor::catchers, ListLockFree::grow(), EventProcessor::OnlyFirst, and EventProcessor::OnlyLast.

Referenced by EventProcessor::connect(), and Event< void(void) >::setup().

void loop (  )  [virtual, inherited]

The method that will be executed once when this class is run in a non periodic thread.

The default implementation calls step() once.

Reimplemented in Timer.

Definition at line 60 of file RunnableInterface.cpp.

References RunnableInterface::step().

Referenced by SlaveActivity::execute(), SingleThread::loop(), and NonPeriodicActivity::loop().

ThreadInterface * getThread (  )  const [inherited]

Get the thread this object is run in.

Returns:
a pointer to the thread or 0 if not run by a thread.

Definition at line 69 of file RunnableInterface.cpp.

Referenced by Timer::initialize().


The documentation for this class was generated from the following files:
Generated on Tue Mar 25 17:41:56 2008 for OrocosReal-TimeToolkit by  doxygen 1.5.3