40 #include <boost/bind.hpp> 42 #ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE 44 #include "../os/MutexLock.hpp" 68 if( !
m_sig )
return false;
73 if (!
m_sig)
return false;
90 #ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE 93 #ifdef ORO_SIGNAL_USE_RT_LIST 94 mconnections.rt_grow(1);
97 mconnections.push_back( d );
100 this->conn_connect( conn );
104 assert( conn.get() &&
"virtually impossible ! only connection base should call this function !" );
106 #ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE 107 mconnections.append( conn );
115 #ifdef ORO_SIGNAL_USE_RT_LIST 116 mconnections.push_back( conn );
121 if ( (tgt = std::find( mconnections.begin(),
123 empty )) != mconnections.end() ) {
131 this->conn_disconnect(conn);
133 #ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE 135 mconnections.shrink(1);
137 #ifdef ORO_SIGNAL_USE_RT_LIST 139 mconnections.rt_shrink(1);
147 assert( conn.get() &&
"virtually impossible ! only connection base should call this function !" );
149 #ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE 150 mconnections.erase( conn );
155 if ( (tgt = std::find( mconnections.begin(),
157 conn)) != mconnections.end() ) {
158 #ifdef ORO_SIGNAL_USE_RT_LIST 160 mconnections.erase( tgt );
173 #ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE 176 void SignalBase::cleanup() {
179 #ifdef ORO_SIGNAL_USE_RT_LIST 181 iterator it = mconnections.begin();
183 const_iterator end = mconnections.end();
184 for (; newit != end && disconcount > 0 ; it=newit ) {
188 if ( it == mconnections.begin() ) {
189 mconnections.erase( it );
190 newit = mconnections.begin();
193 mconnections.erase( it );
200 while ( concount > 0 ) {
201 mconnections.erase( --(mconnections.end()) );
214 #ifdef ORO_SIGNAL_USE_RT_LIST
222 #ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE 234 #ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE 241 #ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE 247 (*tgt)->disconnect();
255 #ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE 258 #ifdef ORO_SIGNAL_USE_RT_LIST 268 #ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE
value_t front() const
Returns the first element of the list.
void ref()
Increase the reference count by one.
The base signal class which stores connection objects.
void reserve(size_t conns)
Reserves memory for a number of connections.
void conn_destroy(connection_t conn)
void reserve(size_t lsize)
Reserve a capacity for this list.
bool empty() const
Returns true if this list is empty.
void RTT_API intrusive_ptr_add_ref(RTT::internal::IntrusiveStorage *p)
virtual ~ConnectionBase()
virtual ~SignalBase()
Deletes this Signal and will destroy all connections and handles of this object.
void RTT_API intrusive_ptr_release(RTT::internal::IntrusiveStorage *p)
boost::intrusive_ptr< ConnectionBase > shared_ptr
bool dec_and_test()
Decrement and test if the result is zero.
void apply(Function func)
Apply a function to the elements of the whole list.
#define ORO_SIGNAL_USE_LIST_LOCK_FREE
void disconnect()
Disconnects all connections.
void conn_disconnect(connection_t conn)
void conn_connect(connection_t conn)
void destroy()
Destroys all connections.
void conn_setup(connection_t conn)
A connection 'memorises' the connection between an event and an event handler function.
os::AtomicInt refcount
We require an internal refcount to ease self-addition and removal of this connection.
void deref()
Decrease the reference count by one and delete this on zero.
connections_list mconnections
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
ConnectionBase::shared_ptr connection_t
bool erase(value_t item)
Erase a value from the list.
MutexLock is a scope based Monitor, protecting critical sections with a Mutex object through locking ...
ConnectionBase(SignalBase *sig)