CompletionProcessor Class Reference
[Event Interface.]

#include </home/sspr/src/www/orocos-1.0/export/build/orocos-rtt-1.2.2/build/rtt/CompletionProcessor.hpp>

Inheritance diagram for CompletionProcessor:

BlockingEventProcessor NonPeriodicActivity EventProcessor ActivityInterface SingleThread RunnableInterface 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.


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.
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 void loop ()
 The method that will be executed once when this class is run in a non periodic thread.
ThreadInterface * getThread () 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 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 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 last fire() call's arguments


Member Function Documentation

static bool Release (  )  [static]

Releases the CompletionProcessor.

Returns:
true on success, false on failure

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.

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.

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

virtual void 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 ExecutionEngine.

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

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.

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.

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

virtual ThreadInterface* thread (  )  [virtual, inherited]

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

Will not be null.

Implements ActivityInterface.

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

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

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

virtual bool trigger (  )  [virtual, inherited]

Trigger that work has to be done.

When you invoke trigger(), you intend to notify the instance 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.

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.

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

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

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


The documentation for this class was generated from the following file:
Generated on Fri Oct 19 16:27:22 2007 for Orocos by  doxygen 1.5.1