39 #ifndef ORO_CORBA_DISPATCHER_HPP 40 #define ORO_CORBA_DISPATCHER_HPP 42 #include "../../os/MutexLock.hpp" 43 #include "../../Activity.hpp" 44 #include "../../base/ChannelElementBase.hpp" 45 #include "../../Logger.hpp" 46 #include "../../internal/List.hpp" 48 #include "../../DataFlowInterface.hpp" 49 #include "../../TaskContext.hpp" 59 typedef std::map<DataFlowInterface*,CorbaDispatcher*> DispatchMap;
60 RTT_CORBA_API
static DispatchMap DispatchI;
69 RTT_CORBA_API
static int defaultScheduler;
70 RTT_CORBA_API
static int defaultPriority;
73 :
Activity(defaultScheduler, defaultPriority, 0.0, 0, name),
79 :
Activity(scheduler, priority, 0.0, 0, name),
100 DispatchMap::iterator result = DispatchI.find(iface);
101 if ( result == DispatchI.end() ) {
104 result = DispatchI.find(iface);
105 if ( result != DispatchI.end() )
106 return result->second;
109 if ( iface == 0 || iface->
getOwner() == 0)
115 DispatchI[iface]->start();
116 return DispatchI[iface];
118 return result->second;
126 DispatchMap::iterator result = DispatchI.find(iface);
127 if ( result != DispatchI.end() ) {
129 delete result->second;
130 DispatchI.erase(result);
132 if ( DispatchI.empty() )
141 DispatchMap::iterator result = DispatchI.begin();
142 while ( result != DispatchI.end() ) {
143 delete result->second;
144 DispatchI.erase(result);
145 result = DispatchI.begin();
153 result = result || (c0 == c1);
157 bool has_element =
false;
165 RClist.
erase( chan );
169 log(
Info) <<
"Started " << this->
getName() <<
"." <<endlog();
175 while ( !RClist.
empty() && !do_exit) {
180 RClist.
erase( chan );
value_t front() const
Returns the first element of the list.
virtual bool stop()
Stop the activity This will stop the activity by removing it from the 'run-queue' of a thread or call...
The Interface of a TaskContext which exposes its data-flow ports.
bool empty() const
Returns true if this list is empty.
Activity(base::RunnableInterface *r=0, const std::string &name="Activity")
Create a not real-time Activity.
void cancelChannel(base::ChannelElementBase::shared_ptr chan)
Base class for CORBA channel servers.
static void hasElement(base::ChannelElementBase::shared_ptr c0, base::ChannelElementBase::shared_ptr c1, bool &result)
virtual void transferSamples()=0
void apply(Function func)
Apply a function to the elements of the whole list.
void dispatchChannel(base::ChannelElementBase::shared_ptr chan)
static void ReleaseAll()
May be called during program termination to clean up all resources.
static CorbaDispatcher * Instance(DataFlowInterface *iface, int scheduler=defaultScheduler, int priority=defaultPriority)
Create a new dispatcher for a given data flow interface.
boost::intrusive_ptr< ChannelElementBase > shared_ptr
An Activity executes a RunnableInterface object in a (periodic) thread.
This object sends over data flow messages from local buffers to a remote channel element.
An object oriented wrapper around a non recursive mutex.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
static void Release(DataFlowInterface *iface)
Releases and cleans up a specific interface from dispatching.
virtual bool trigger()
Trigger that work has to be done.
bool append(value_t item)
Append a single value to the list.
bool erase(value_t item)
Erase a value from the list.
virtual const char * getName() const
Read the name of this task.
virtual const std::string & getName() const
Returns the name of this TaskContext.
TaskContext * getOwner() const
Returns the component this interface belongs to.
MutexLock is a scope based Monitor, protecting critical sections with a Mutex object through locking ...