37 #include <boost/scope_exit.hpp> 55 boost::mutex::scoped_lock lock(
mutex_);
63 boost::mutex::scoped_lock lock(
mutex_);
71 boost::mutex::scoped_lock lock(
mutex_);
78 boost::mutex::scoped_lock lock(
mutex_);
85 boost::mutex::scoped_lock lock(
mutex_);
107 M_IDInfo::iterator it =
id_info_.find(removal_id);
110 IDInfoPtr id_info(boost::make_shared<IDInfo>());
111 id_info->id = removal_id;
112 id_info_.insert(std::make_pair(removal_id, id_info));
117 boost::mutex::scoped_lock lock(
mutex_);
133 M_IDInfo::iterator it =
id_info_.find(
id);
150 M_IDInfo::iterator it =
id_info_.find(removal_id);
153 id_info = it->second;
163 if (
tls_->calling_in_this_thread == id_info->id)
165 id_info->calling_rw_mutex.unlock_shared();
169 boost::unique_lock<boost::shared_mutex> rw_lock(id_info->calling_rw_mutex);
170 boost::mutex::scoped_lock lock(
mutex_);
171 D_CallbackInfo::iterator it =
callbacks_.begin();
186 if (
tls_->calling_in_this_thread == id_info->id)
188 id_info->calling_rw_mutex.lock_shared();
195 D_CallbackInfo::iterator it =
tls_->callbacks.begin();
196 D_CallbackInfo::iterator end =
tls_->callbacks.end();
197 for (; it != end; ++it)
221 boost::mutex::scoped_lock lock(
mutex_);
246 D_CallbackInfo::iterator it =
callbacks_.begin();
285 boost::mutex::scoped_lock lock(
mutex_);
297 boost::mutex::scoped_lock lock(
mutex_);
341 boost::mutex::scoped_lock lock(
mutex_);
369 boost::shared_lock<boost::shared_mutex> rw_lock(id_info->calling_rw_mutex);
380 BOOST_SCOPE_EXIT(&tls, &last_calling)
386 if (info.marked_for_removal)
400 boost::mutex::scoped_lock lock(
mutex_);
CallResult
Possible results for the call() method.
boost::thread_specific_ptr< TLS > tls_
D_CallbackInfo::iterator cb_it
void disable()
Disable the queue, meaning any calls to addCallback() will have no effect.
virtual void addCallback(const CallbackInterfacePtr &callback, uint64_t removal_id=0)
Add a callback, with an optional owner id. The owner id can be used to remove a set of callbacks from...
void enable()
Enable the queue (queue is enabled by default)
ros::internal::condition_variable_monotonic condition_
CallOneResult callOne()
Pop a single callback off the front of the queue and invoke it. If the callback was not ready to be c...
D_CallbackInfo callbacks_
boost::shared_ptr< IDInfo > IDInfoPtr
CallbackQueue(bool enabled=true)
void callAvailable()
Invoke all callbacks currently in the queue. If a callback was not ready to be called, pushes it back onto the queue.
CallOneResult callOneCB(TLS *tls)
bool isEnabled()
Returns whether or not this queue is enabled.
boost::mutex id_info_mutex_
virtual void removeByID(uint64_t removal_id)
Remove all callbacks associated with an owner id.
Call not ready, try again later.
IDInfoPtr getIDInfo(uint64_t id)
uint64_t calling_in_this_thread
CallbackInterfacePtr callback
bool isEmpty()
returns whether or not the queue is empty
void clear()
Removes all callbacks from the queue. Does not wait for calls currently in progress to finish...