37 #define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC 42 #include <boost/scope_exit.hpp> 46 #if BOOST_VERSION < 106100 47 #ifndef USING_BACKPORTED_BOOST_CONDITION_VARIABLE 48 #error "needs boost version >= 1.61 or the backported headers!" 68 boost::mutex::scoped_lock lock(
mutex_);
76 boost::mutex::scoped_lock lock(
mutex_);
84 boost::mutex::scoped_lock lock(
mutex_);
91 boost::mutex::scoped_lock lock(
mutex_);
98 boost::mutex::scoped_lock lock(
mutex_);
120 M_IDInfo::iterator it =
id_info_.find(removal_id);
123 IDInfoPtr id_info(boost::make_shared<IDInfo>());
124 id_info->id = removal_id;
125 id_info_.insert(std::make_pair(removal_id, id_info));
130 boost::mutex::scoped_lock lock(
mutex_);
146 M_IDInfo::iterator it =
id_info_.find(
id);
163 M_IDInfo::iterator it =
id_info_.find(removal_id);
166 id_info = it->second;
176 if (
tls_->calling_in_this_thread == id_info->id)
178 id_info->calling_rw_mutex.unlock_shared();
182 boost::unique_lock<boost::shared_mutex> rw_lock(id_info->calling_rw_mutex);
183 boost::mutex::scoped_lock lock(
mutex_);
184 D_CallbackInfo::iterator it =
callbacks_.begin();
199 if (
tls_->calling_in_this_thread == id_info->id)
201 id_info->calling_rw_mutex.lock_shared();
208 D_CallbackInfo::iterator it =
tls_->callbacks.begin();
209 D_CallbackInfo::iterator end =
tls_->callbacks.end();
210 for (; it != end; ++it)
234 boost::mutex::scoped_lock lock(
mutex_);
259 D_CallbackInfo::iterator it =
callbacks_.begin();
298 boost::mutex::scoped_lock lock(
mutex_);
310 boost::mutex::scoped_lock lock(
mutex_);
354 boost::mutex::scoped_lock lock(
mutex_);
382 boost::shared_lock<boost::shared_mutex> rw_lock(id_info->calling_rw_mutex);
393 BOOST_SCOPE_EXIT(&tls, &last_calling)
399 if (info.marked_for_removal)
413 boost::mutex::scoped_lock lock(
mutex_);
void notify_all() BOOST_NOEXCEPT
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)
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
boost::condition_variable condition_
CallbackInterfacePtr callback
bool isEmpty()
returns whether or not the queue is empty
void notify_one() BOOST_NOEXCEPT
void clear()
Removes all callbacks from the queue. Does not wait for calls currently in progress to finish...