CompletionProcessor Class Reference
[Event Interface.]

#include <rtt/CompletionProcessor.hpp>

Inheritance diagram for CompletionProcessor:

BlockingEventProcessor NonPeriodicActivity EventProcessor ActivityInterface SingleThread RunnableInterface

List of all members.


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.


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...

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 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.
bool run (RunnableInterface *r)
 Run another (or self in case of null) task.
bool run (int)
 Run another (or self in case of null) task.
virtual Seconds getPeriod () const
 Get the periodicity of this activity in Seconds.
virtual ThreadInterfacethread ()
 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 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

 CompletionProcessor ()
 Constructor.
void destroyed (detail::EventCatcher *ec)

Protected Attributes

List catchers

Friends

class detail::EventCatcher

Member Enumeration Documentation

enum AsynStorageType [inherited]

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


Member Function Documentation

bool Release (  )  [static]

Releases the CompletionProcessor.

Returns:
true on success, false on failure

Definition at line 71 of file CompletionProcessor.cpp.

Handle 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 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, 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 551 of file EventProcessor.hpp.

References ListLockFree::append(), ListLockFree::grow(), 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().

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().

bool 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 110 of file NonPeriodicActivity.hpp.

References NonPeriodicActivity::run().

Seconds getPeriod (  )  const [virtual, inherited]

Get the periodicity of this activity in Seconds.

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

Implements ActivityInterface.

Definition at line 90 of file NonPeriodicActivity.cpp.

OS::ThreadInterface * thread (  )  [virtual, inherited]

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

Will not be null.

Implements ActivityInterface.

Definition at line 92 of file NonPeriodicActivity.cpp.

Referenced by CompletionProcessor::CompletionProcessor().

bool 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 ActivityInterface.

Definition at line 94 of file NonPeriodicActivity.cpp.

bool 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 ActivityInterface.

Definition at line 119 of file NonPeriodicActivity.cpp.

References SingleThread::start().

bool 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.

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 ActivityInterface.

Definition at line 131 of file NonPeriodicActivity.cpp.

bool 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.

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 ActivityInterface.

Definition at line 127 of file NonPeriodicActivity.cpp.

References SingleThread::isActive(), and SingleThread::start().

bool 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 ActivityInterface.

Definition at line 123 of file NonPeriodicActivity.cpp.

References SingleThread::stop().

bool 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 ActivityInterface.

Definition at line 135 of file NonPeriodicActivity.cpp.

References SingleThread::isRunning().

bool 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 ActivityInterface.

Definition at line 139 of file NonPeriodicActivity.cpp.

References SingleThread::isActive().

Referenced by NonPeriodicActivity::run().


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

Generated on Mon Jan 19 16:53:56 2009 for OrocosReal-TimeToolkit by  doxygen 1.5.6