RTT::CompletionProcessor Class Reference
[Event Interface.]

An activity which executes asynchronous (defered) handlers of Events. More...

#include <rtt/CompletionProcessor.hpp>

Inheritance diagram for RTT::CompletionProcessor:
RTT::BlockingEventProcessor RTT::NonPeriodicActivity RTT::EventProcessor RTT::ActivityInterface RTT::OS::SingleThread RTT::RunnableInterface RTT::OS::RunnableInterface

List of all members.

Public Types

typedef CompletionProcessorCompletionProcessorPtr
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...
typedef boost::shared_ptr
< ActivityInterface
shared_ptr

Public Member Functions

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 RTT_API 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.
bool hasWork ()
 This method is for 'intelligent' activity implementations that wish to see if it is required to call step() (again).
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.
ActivityInterfacegetActivity () const
 Query for the task this interface is run in.
virtual void setActivity (ActivityInterface *task)
 Set the task this interface is run in.
virtual OS::ThreadInterfacegetThread () const
 Get the thread this object is run in.
virtual void loop ()
 The method that will be executed once when this class RTT_API is run in a non periodic thread.
virtual void setThread (ThreadInterface *t)
 Set the thread this object will be run in.
bool run (int)
 Run another (or self in case of null) task.
virtual bool run (RunnableInterface *r)
 Run exclusively this RunnableInterface.
virtual Seconds getPeriod () const
 Get the periodicity of this activity in Seconds.
virtual ThreadInterface * thread ()
 Returns a pointer to the thread which will run this activity.
virtual bool initialize ()
virtual void loop ()
virtual bool breakLoop ()
virtual void finalize ()
virtual bool isPeriodic () const
 Inspect if this activity is periodic.
virtual bool start ()
 Start the activity.
virtual bool execute ()
 Execute this activity such that it executes a step or loop of the RunnableInterface.
virtual bool trigger ()
 Trigger that work has to be done.
virtual bool stop ()
 Stop the activity This will stop the activity by removing it from the 'run-queue' of a thread or call RunnableInterface::breakLoop().
virtual bool isRunning () const
 Query if the activity is initialized and executing.
virtual bool isActive () const
 Query if the activity is started.

Static Public Member Functions

static CompletionProcessorPtr Instance ()
 Returns the unique (singleton) CompletionProcessor.
static bool Release ()
 Releases the CompletionProcessor.

Protected Types

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

Protected Member Functions

 CompletionProcessor ()
 Constructor.
void destroyed (detail::EventCatcher *ec)
void disableRun (RunnableInterface *caller)
 This method is only meant for RunnableInterface (ie runner) in order to inform the ActivityInterface it should no longer be used.

Protected Attributes

ECList catchers
OS::AtomicInt has_work
RunnableInterfacerunner

Friends

struct EventCatcher
struct detail::EventCatcher
class RunnableInterface

Detailed Description

An activity which executes asynchronous (defered) handlers of Events.

This is an utility class which can be used to execute Event callback functions in a thread. It's purpose is to allow a way to process not real-time event callback functions, without disturbing the emitor of the event. If the user requires a not real-time, complex or lengthy callback execution, it can be done in this activity.

Definition at line 44 of file CompletionProcessor.hpp.


Member Enumeration Documentation

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:
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 533 of file EventProcessor.hpp.


Member Function Documentation

template<class SignalType >
Handle RTT::EventProcessor::connect ( const typename SignalType::SlotFunction &  f,
SignalType &  sig,
AsynStorageType  t 
) [inline, inherited]

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 569 of file EventProcessor.hpp.

References RTT::Handle::connect().

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

void RTT::ActivityInterface::disableRun ( RunnableInterface caller  )  [inline, protected, inherited]

This method is only meant for RunnableInterface (ie runner) in order to inform the ActivityInterface it should no longer be used.

run(0) can not be used in this case because it would recurse.

Definition at line 73 of file ActivityInterface.hpp.

virtual bool RTT::NonPeriodicActivity::execute (  )  [virtual, inherited]

Execute this activity such that it executes a step or loop of the RunnableInterface.

When you invoke execute() you intend to call the step() or loop() methods. Some activity implementations allow a user controlled execute, others ignore it, in which case execute() returns false.

Semantics: If execute() returns true, the activity has been executed exactly once during execute().

Return values:
true When this->isActive() and the implementation allows external executes.
false When !this->isActive() or the implementation does not allow external updating.
See also:
trigger() for use in callbacks which want execute() to be executed.

Implements RTT::ActivityInterface.

ActivityInterface * RTT::RunnableInterface::getActivity (  )  const [inline, inherited]

Query for the task this interface is run in.

Zero denotes that no task is present to run it, and hence no detailed information is available.

Returns:
The Activity which runs this RunnableInterface.

Definition at line 106 of file RunnableInterface.hpp.

virtual Seconds RTT::NonPeriodicActivity::getPeriod (  )  const [virtual, inherited]

Get the periodicity of this activity in Seconds.

Returns:
The execution period of this activity (zero if !this->isPeriodic() ).

Implements RTT::ActivityInterface.

virtual OS::ThreadInterface* RTT::RunnableInterface::getThread (  )  const [virtual, inherited]

Get the thread this object is run in.

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

Reimplemented from RTT::OS::RunnableInterface.

bool RTT::EventProcessor::hasWork (  )  [virtual, inherited]

This method is for 'intelligent' activity implementations that wish to see if it is required to call step() (again).

By default, false is returned. You should only return true in case there is a temporary reason to (re-)run step.

Returns:
true if this object should be run.
See also:
SequentialActivity implementation to see how this can be of use.

Reimplemented from RTT::RunnableInterface.

virtual bool RTT::NonPeriodicActivity::isActive (  )  const [virtual, inherited]

Query if the activity is started.

This is less strict than isRunning(), it is true during initialize(), step() or loop() and finalize(). Use this method to check if an activity was start()ed.

Returns:
true if it is active, false otherwise

Implements RTT::ActivityInterface.

virtual bool RTT::NonPeriodicActivity::isPeriodic (  )  const [virtual, inherited]

Inspect if this activity is periodic.

If so, it will call RunnableInterface::step(). If the activity is not periodic, it will call RunnableInterface::loop().

Returns:
true if periodic.

Implements RTT::ActivityInterface.

virtual bool RTT::NonPeriodicActivity::isRunning (  )  const [virtual, inherited]

Query if the activity is initialized and executing.

This is more strict than isActive(), it is only true after initialize() is executed and before finalize() is executed. More-over, an Activity may decide to be temporarily not running (not executing code), waiting for a signal to proceed. If this->isActive() and !this->isRunning() then the Activity is in a waiting state.

Returns:
true if it is running, false otherwise

Implements RTT::ActivityInterface.

virtual void RTT::OS::RunnableInterface::loop (  )  [virtual, inherited]

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

The default implementation calls step() once.

Reimplemented in RTT::Timer.

static bool RTT::CompletionProcessor::Release (  )  [static]

Releases the CompletionProcessor.

Returns:
true on success, false on failure
virtual bool RTT::ActivityInterface::run ( RunnableInterface r  )  [virtual, inherited]

Run exclusively this RunnableInterface.

Precondition:
this->isRunning() == false
Parameters:
r The RunnableInterface to run exclusively.
Returns:
true if succeeded, false otherwise

Referenced by RTT::NonPeriodicActivity::run().

bool RTT::NonPeriodicActivity::run ( int   )  [inline, inherited]

Run another (or self in case of null) task.

This overload is needed to redirect the call of run( 0 ) to the correct function.

Definition at line 105 of file NonPeriodicActivity.hpp.

References RTT::ActivityInterface::run().

virtual void RTT::RunnableInterface::setActivity ( ActivityInterface task  )  [virtual, inherited]

Set the task this interface is run in.

A Zero means no task is running it.

Parameters:
task The ActivityInterface running this interface.

Reimplemented in RTT::ExecutionEngine.

template<class SignalType >
Handle RTT::EventProcessor::setup ( const typename SignalType::SlotFunction &  f,
SignalType &  sig,
AsynStorageType  t 
) [inline, inherited]

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 587 of file EventProcessor.hpp.

Referenced by RTT::Event< void() >::setup().

virtual bool RTT::NonPeriodicActivity::start (  )  [virtual, inherited]

Start the activity.

This will call RunnableInterface::initialize() and upon success, effectively start the activity, by running the RunnableInterface::step() or RunnableInterface::loop() in a thread.

See also:
isPeriodic()
Returns:
true if the activity is started, false otherwise

Implements RTT::ActivityInterface.

Reimplemented in RTT::EventDrivenActivity.

virtual bool RTT::NonPeriodicActivity::stop (  )  [virtual, inherited]

Stop the activity This will stop the activity by removing it from the 'run-queue' of a thread or call RunnableInterface::breakLoop().

If no errors occured, RunnableInterface::finalize() is called.

See also:
isPeriodic()
Returns:
true if the activity is stopped, false otherwise

Implements RTT::ActivityInterface.

Reimplemented in RTT::EventDrivenActivity.

virtual ThreadInterface* RTT::NonPeriodicActivity::thread (  )  [virtual, inherited]

Returns a pointer to the thread which will run this activity.

Will not be null.

Implements RTT::ActivityInterface.

virtual bool RTT::NonPeriodicActivity::trigger (  )  [virtual, inherited]

Trigger that work has to be done.

When you invoke trigger(), you intend to notify the mechanism that calls execute(), that execute() should be called. This allows a separation between actually executing code (execute()) and notifying that code must be executed (trigger()). A trigger may be ignored by the implementation, in which case trigger returns false.

Semantics: If trigger() returns true, the activity will be executed at least once from the moment trigger() is called.

Return values:
true When this->isActive() and the implementation allows external triggers.
false When !this->isActive() or the implementation does not allow external triggering.

Implements RTT::ActivityInterface.


The documentation for this class was generated from the following file:
Generated on Thu Dec 23 13:22:40 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3