mirror of
https://github.com/boostorg/thread.git
synced 2026-02-15 01:22:08 +00:00
Cleanup header includes.
1. Make inclusion of boost/bind/bind.hpp conditional in some cases, when the code actually conditionally uses boost::bind. Reduces compile-time overhead and fixes https://github.com/boostorg/thread/issues/307. 2. Remove some unnecessary uses of boost::ref. This allows to avoid including boost/core/ref.hpp in a few places, and avoids the associated template instantiation overhead in others. 3. Replace deprecated header includes with the more recent alternatives. For example: boost/detail/lightweight_test.hpp -> boost/core/lightweight_test.hpp, boost/ref.hpp -> boost/core/ref.hpp. 4. Replace some blanket includes with the more fine-grained ones. For example, boost/utility.hpp, boost/atomic.hpp. This reduces compile time overhead. 5. Add some missing includes, for example, boost/core/ref.hpp and boost/type_traits/is_same.hpp. 6. Replace uses of std::is_same with boost::is_same (with the corresponding included header) since the standard type_traits header presence and validity is not tested by the code. Using boost::is_same makes the code more portable.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
|
||||
#include <boost/thread/detail/config.hpp>
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
@@ -187,7 +188,7 @@ namespace detail
|
||||
template <class ValueType, class Queue>
|
||||
bool sync_deque_base<ValueType, Queue>::wait_until_not_empty_or_closed(unique_lock<mutex>& lk)
|
||||
{
|
||||
cond_.wait(lk, boost::bind(&sync_deque_base<ValueType, Queue>::not_empty_or_closed, boost::ref(*this), boost::ref(lk)));
|
||||
cond_.wait(lk, boost::bind(&sync_deque_base<ValueType, Queue>::not_empty_or_closed, this, boost::ref(lk)));
|
||||
if (! empty(lk)) return false; // success
|
||||
return true; // closed
|
||||
}
|
||||
@@ -196,7 +197,7 @@ namespace detail
|
||||
template <class WClock, class Duration>
|
||||
queue_op_status sync_deque_base<ValueType, Queue>::wait_until_not_empty_or_closed_until(unique_lock<mutex>& lk, chrono::time_point<WClock,Duration> const&tp)
|
||||
{
|
||||
if (! cond_.wait_until(lk, tp, boost::bind(&sync_deque_base<ValueType, Queue>::not_empty_or_closed, boost::ref(*this), boost::ref(lk))))
|
||||
if (! cond_.wait_until(lk, tp, boost::bind(&sync_deque_base<ValueType, Queue>::not_empty_or_closed, this, boost::ref(lk))))
|
||||
return queue_op_status::timeout;
|
||||
if (! empty(lk)) return queue_op_status::success;
|
||||
return queue_op_status::closed;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/core/ref.hpp>
|
||||
|
||||
#include <boost/thread/detail/config.hpp>
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
@@ -187,7 +188,7 @@ namespace detail
|
||||
template <class ValueType, class Queue>
|
||||
bool sync_queue_base<ValueType, Queue>::wait_until_not_empty_or_closed(unique_lock<mutex>& lk)
|
||||
{
|
||||
cond_.wait(lk, boost::bind(&sync_queue_base<ValueType, Queue>::not_empty_or_closed, boost::ref(*this), boost::ref(lk)));
|
||||
cond_.wait(lk, boost::bind(&sync_queue_base<ValueType, Queue>::not_empty_or_closed, this, boost::ref(lk)));
|
||||
if (! empty(lk)) return false; // success
|
||||
return true; // closed
|
||||
}
|
||||
@@ -196,7 +197,7 @@ namespace detail
|
||||
template <class WClock, class Duration>
|
||||
queue_op_status sync_queue_base<ValueType, Queue>::wait_until_not_empty_or_closed_until(unique_lock<mutex>& lk, chrono::time_point<WClock,Duration> const&tp)
|
||||
{
|
||||
if (! cond_.wait_until(lk, tp, boost::bind(&sync_queue_base<ValueType, Queue>::not_empty_or_closed, boost::ref(*this), boost::ref(lk))))
|
||||
if (! cond_.wait_until(lk, tp, boost::bind(&sync_queue_base<ValueType, Queue>::not_empty_or_closed, this, boost::ref(lk))))
|
||||
return queue_op_status::timeout;
|
||||
if (! empty(lk)) return queue_op_status::success;
|
||||
return queue_op_status::closed;
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <algorithm>
|
||||
#include <boost/core/ref.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <stdlib.h>
|
||||
#include <memory>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
@@ -47,6 +46,8 @@
|
||||
|
||||
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
|
||||
#include <tuple>
|
||||
#else
|
||||
#include <boost/bind/bind.hpp>
|
||||
#endif
|
||||
#include <boost/config/abi_prefix.hpp>
|
||||
|
||||
|
||||
@@ -393,7 +393,7 @@ namespace boost
|
||||
is_deferred_=false;
|
||||
execute(lk);
|
||||
}
|
||||
waiters.wait(lk, boost::bind(&shared_state_base::is_done, boost::ref(*this)));
|
||||
waiters.wait(lk, boost::bind(&shared_state_base::is_done, this));
|
||||
if(rethrow && exception)
|
||||
{
|
||||
boost::rethrow_exception(exception);
|
||||
@@ -420,7 +420,7 @@ namespace boost
|
||||
return false;
|
||||
|
||||
do_callback(lock);
|
||||
return waiters.timed_wait(lock, rel_time, boost::bind(&shared_state_base::is_done, boost::ref(*this)));
|
||||
return waiters.timed_wait(lock, rel_time, boost::bind(&shared_state_base::is_done, this));
|
||||
}
|
||||
|
||||
bool timed_wait_until(boost::system_time const& target_time)
|
||||
@@ -430,7 +430,7 @@ namespace boost
|
||||
return false;
|
||||
|
||||
do_callback(lock);
|
||||
return waiters.timed_wait(lock, target_time, boost::bind(&shared_state_base::is_done, boost::ref(*this)));
|
||||
return waiters.timed_wait(lock, target_time, boost::bind(&shared_state_base::is_done, this));
|
||||
}
|
||||
#endif
|
||||
#ifdef BOOST_THREAD_USES_CHRONO
|
||||
@@ -443,7 +443,7 @@ namespace boost
|
||||
if (is_deferred_)
|
||||
return future_status::deferred;
|
||||
do_callback(lock);
|
||||
if(!waiters.wait_until(lock, abs_time, boost::bind(&shared_state_base::is_done, boost::ref(*this))))
|
||||
if(!waiters.wait_until(lock, abs_time, boost::bind(&shared_state_base::is_done, this)))
|
||||
{
|
||||
return future_status::timeout;
|
||||
}
|
||||
@@ -940,7 +940,7 @@ namespace boost
|
||||
join();
|
||||
#elif defined BOOST_THREAD_ASYNC_FUTURE_WAITS
|
||||
unique_lock<boost::mutex> lk(this->mutex);
|
||||
this->waiters.wait(lk, boost::bind(&shared_state_base::is_done, boost::ref(*this)));
|
||||
this->waiters.wait(lk, boost::bind(&shared_state_base::is_done, this));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -19,14 +19,17 @@
|
||||
#include <boost/thread/detail/delete.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config/abi_prefix.hpp>
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <pthread.h>
|
||||
#include <csignal>
|
||||
|
||||
#if !defined(BOOST_THREAD_PROVIDES_INVOKE) && !defined(BOOST_THREAD_PROVIDES_INVOKE_RET)
|
||||
#include <boost/bind/bind.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/config/abi_prefix.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
#include <boost/thread/detail/move.hpp>
|
||||
#include <boost/thread/detail/invoke.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/atomic/capabilities.hpp>
|
||||
#include <boost/atomic/atomic.hpp>
|
||||
|
||||
#if !defined(BOOST_THREAD_PROVIDES_INVOKE) && !defined(BOOST_THREAD_PROVIDES_INVOKE_RET)
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/atomic.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/config/abi_prefix.hpp>
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace boost
|
||||
boost::this_thread::disable_interruption do_not_disturb;
|
||||
#endif
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
shared_cond.wait(lk, boost::bind(&state_data::can_lock_shared, boost::ref(state)));
|
||||
shared_cond.wait(lk, boost::bind(&state_data::can_lock_shared, &state));
|
||||
state.lock_shared();
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ namespace boost
|
||||
boost::this_thread::disable_interruption do_not_disturb;
|
||||
#endif
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
if(!shared_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock_shared, boost::ref(state))))
|
||||
if(!shared_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock_shared, &state)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -209,7 +209,7 @@ namespace boost
|
||||
boost::this_thread::disable_interruption do_not_disturb;
|
||||
#endif
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
if(!shared_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock_shared, boost::ref(state))))
|
||||
if(!shared_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock_shared, &state)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -230,7 +230,7 @@ namespace boost
|
||||
boost::this_thread::disable_interruption do_not_disturb;
|
||||
#endif
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_shared, boost::ref(state))))
|
||||
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_shared, &state)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -270,7 +270,7 @@ namespace boost
|
||||
#endif
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
state.exclusive_waiting_blocked=true;
|
||||
exclusive_cond.wait(lk, boost::bind(&state_data::can_lock, boost::ref(state)));
|
||||
exclusive_cond.wait(lk, boost::bind(&state_data::can_lock, &state));
|
||||
state.exclusive=true;
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ namespace boost
|
||||
#endif
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
state.exclusive_waiting_blocked=true;
|
||||
if(!exclusive_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock, boost::ref(state))))
|
||||
if(!exclusive_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock, &state)))
|
||||
{
|
||||
state.exclusive_waiting_blocked=false;
|
||||
release_waiters();
|
||||
@@ -300,7 +300,7 @@ namespace boost
|
||||
#endif
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
state.exclusive_waiting_blocked=true;
|
||||
if(!exclusive_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock, boost::ref(state))))
|
||||
if(!exclusive_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock, &state)))
|
||||
{
|
||||
state.exclusive_waiting_blocked=false;
|
||||
release_waiters();
|
||||
@@ -324,7 +324,7 @@ namespace boost
|
||||
#endif
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
state.exclusive_waiting_blocked=true;
|
||||
if(!exclusive_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock, boost::ref(state))))
|
||||
if(!exclusive_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock, &state)))
|
||||
{
|
||||
state.exclusive_waiting_blocked=false;
|
||||
release_waiters();
|
||||
@@ -362,7 +362,7 @@ namespace boost
|
||||
boost::this_thread::disable_interruption do_not_disturb;
|
||||
#endif
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
shared_cond.wait(lk, boost::bind(&state_data::can_lock_upgrade, boost::ref(state)));
|
||||
shared_cond.wait(lk, boost::bind(&state_data::can_lock_upgrade, &state));
|
||||
state.lock_shared();
|
||||
state.upgrade=true;
|
||||
}
|
||||
@@ -374,7 +374,7 @@ namespace boost
|
||||
boost::this_thread::disable_interruption do_not_disturb;
|
||||
#endif
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
if(!shared_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock_upgrade, boost::ref(state))))
|
||||
if(!shared_cond.timed_wait(lk, timeout, boost::bind(&state_data::can_lock_upgrade, &state)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -390,7 +390,7 @@ namespace boost
|
||||
boost::this_thread::disable_interruption do_not_disturb;
|
||||
#endif
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
if(!shared_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock_upgrade, boost::ref(state))))
|
||||
if(!shared_cond.timed_wait(lk, relative_time, boost::bind(&state_data::can_lock_upgrade, &state)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -412,7 +412,7 @@ namespace boost
|
||||
boost::this_thread::disable_interruption do_not_disturb;
|
||||
#endif
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_upgrade, boost::ref(state))))
|
||||
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_upgrade, &state)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -457,7 +457,7 @@ namespace boost
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
state.assert_lock_upgraded();
|
||||
state.unlock_shared();
|
||||
upgrade_cond.wait(lk, boost::bind(&state_data::no_shared, boost::ref(state)));
|
||||
upgrade_cond.wait(lk, boost::bind(&state_data::no_shared, &state));
|
||||
state.upgrade=false;
|
||||
state.exclusive=true;
|
||||
state.assert_locked();
|
||||
@@ -511,7 +511,7 @@ namespace boost
|
||||
#endif
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
state.assert_lock_upgraded();
|
||||
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::one_shared, boost::ref(state))))
|
||||
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::one_shared, &state)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -569,7 +569,7 @@ namespace boost
|
||||
#endif
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
state.assert_lock_shared();
|
||||
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::one_shared, boost::ref(state))))
|
||||
if(!shared_cond.wait_until(lk, abs_time, boost::bind(&state_data::one_shared, &state)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -623,7 +623,7 @@ namespace boost
|
||||
#endif
|
||||
boost::unique_lock<boost::mutex> lk(state_change);
|
||||
state.assert_lock_shared();
|
||||
if(!exclusive_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_upgrade, boost::ref(state))))
|
||||
if(!exclusive_cond.wait_until(lk, abs_time, boost::bind(&state_data::can_lock_upgrade, &state)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -275,9 +275,9 @@ namespace boost {
|
||||
inline void shared_mutex::lock()
|
||||
{
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
gate1_.wait(lk, boost::bind(&shared_mutex::no_writer, boost::ref(*this)));
|
||||
gate1_.wait(lk, boost::bind(&shared_mutex::no_writer, this));
|
||||
state_ |= write_entered_;
|
||||
gate2_.wait(lk, boost::bind(&shared_mutex::no_readers, boost::ref(*this)));
|
||||
gate2_.wait(lk, boost::bind(&shared_mutex::no_readers, this));
|
||||
}
|
||||
|
||||
inline bool shared_mutex::try_lock()
|
||||
@@ -298,13 +298,13 @@ namespace boost {
|
||||
{
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
if (!gate1_.wait_until(lk, abs_time, boost::bind(
|
||||
&shared_mutex::no_writer, boost::ref(*this))))
|
||||
&shared_mutex::no_writer, this)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
state_ |= write_entered_;
|
||||
if (!gate2_.wait_until(lk, abs_time, boost::bind(
|
||||
&shared_mutex::no_readers, boost::ref(*this))))
|
||||
&shared_mutex::no_readers, this)))
|
||||
{
|
||||
state_ &= ~write_entered_;
|
||||
return false;
|
||||
@@ -319,13 +319,13 @@ namespace boost {
|
||||
{
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
if (!gate1_.timed_wait(lk, abs_or_rel_time, boost::bind(
|
||||
&shared_mutex::no_writer, boost::ref(*this))))
|
||||
&shared_mutex::no_writer, this)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
state_ |= write_entered_;
|
||||
if (!gate2_.timed_wait(lk, abs_or_rel_time, boost::bind(
|
||||
&shared_mutex::no_readers, boost::ref(*this))))
|
||||
&shared_mutex::no_readers, this)))
|
||||
{
|
||||
state_ &= ~write_entered_;
|
||||
return false;
|
||||
@@ -350,7 +350,7 @@ namespace boost {
|
||||
inline void shared_mutex::lock_shared()
|
||||
{
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
gate1_.wait(lk, boost::bind(&shared_mutex::no_writer_no_max_readers, boost::ref(*this)));
|
||||
gate1_.wait(lk, boost::bind(&shared_mutex::no_writer_no_max_readers, this));
|
||||
count_t num_readers = (state_ & n_readers_) + 1;
|
||||
state_ &= ~n_readers_;
|
||||
state_ |= num_readers;
|
||||
@@ -376,7 +376,7 @@ namespace boost {
|
||||
{
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
if (!gate1_.wait_until(lk, abs_time, boost::bind(
|
||||
&shared_mutex::no_writer_no_max_readers, boost::ref(*this))))
|
||||
&shared_mutex::no_writer_no_max_readers, this)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -393,7 +393,7 @@ namespace boost {
|
||||
{
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
if (!gate1_.timed_wait(lk, abs_or_rel_time, boost::bind(
|
||||
&shared_mutex::no_writer_no_max_readers, boost::ref(*this))))
|
||||
&shared_mutex::no_writer_no_max_readers, this)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -653,9 +653,9 @@ namespace boost {
|
||||
inline void upgrade_mutex::lock()
|
||||
{
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
gate1_.wait(lk, boost::bind(&upgrade_mutex::no_writer_no_upgrader, boost::ref(*this)));
|
||||
gate1_.wait(lk, boost::bind(&upgrade_mutex::no_writer_no_upgrader, this));
|
||||
state_ |= write_entered_;
|
||||
gate2_.wait(lk, boost::bind(&upgrade_mutex::no_readers, boost::ref(*this)));
|
||||
gate2_.wait(lk, boost::bind(&upgrade_mutex::no_readers, this));
|
||||
}
|
||||
|
||||
inline bool upgrade_mutex::try_lock()
|
||||
@@ -676,13 +676,13 @@ namespace boost {
|
||||
{
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
if (!gate1_.wait_until(lk, abs_time, boost::bind(
|
||||
&upgrade_mutex::no_writer_no_upgrader, boost::ref(*this))))
|
||||
&upgrade_mutex::no_writer_no_upgrader, this)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
state_ |= write_entered_;
|
||||
if (!gate2_.wait_until(lk, abs_time, boost::bind(
|
||||
&upgrade_mutex::no_readers, boost::ref(*this))))
|
||||
&upgrade_mutex::no_readers, this)))
|
||||
{
|
||||
state_ &= ~write_entered_;
|
||||
return false;
|
||||
@@ -697,13 +697,13 @@ namespace boost {
|
||||
{
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
if (!gate1_.timed_wait(lk, abs_or_rel_time, boost::bind(
|
||||
&upgrade_mutex::no_writer_no_upgrader, boost::ref(*this))))
|
||||
&upgrade_mutex::no_writer_no_upgrader, this)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
state_ |= write_entered_;
|
||||
if (!gate2_.timed_wait(lk, abs_or_rel_time, boost::bind(
|
||||
&upgrade_mutex::no_readers, boost::ref(*this))))
|
||||
&upgrade_mutex::no_readers, this)))
|
||||
{
|
||||
state_ &= ~write_entered_;
|
||||
return false;
|
||||
@@ -729,7 +729,7 @@ namespace boost {
|
||||
inline void upgrade_mutex::lock_shared()
|
||||
{
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
gate1_.wait(lk, boost::bind(&upgrade_mutex::no_writer_no_max_readers, boost::ref(*this)));
|
||||
gate1_.wait(lk, boost::bind(&upgrade_mutex::no_writer_no_max_readers, this));
|
||||
count_t num_readers = (state_ & n_readers_) + 1;
|
||||
state_ &= ~n_readers_;
|
||||
state_ |= num_readers;
|
||||
@@ -755,7 +755,7 @@ namespace boost {
|
||||
{
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
if (!gate1_.wait_until(lk, abs_time, boost::bind(
|
||||
&upgrade_mutex::no_writer_no_max_readers, boost::ref(*this))))
|
||||
&upgrade_mutex::no_writer_no_max_readers, this)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -772,7 +772,7 @@ namespace boost {
|
||||
{
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
if (!gate1_.timed_wait(lk, abs_or_rel_time, boost::bind(
|
||||
&upgrade_mutex::no_writer_no_max_readers, boost::ref(*this))))
|
||||
&upgrade_mutex::no_writer_no_max_readers, this)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -807,7 +807,7 @@ namespace boost {
|
||||
inline void upgrade_mutex::lock_upgrade()
|
||||
{
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
gate1_.wait(lk, boost::bind(&upgrade_mutex::no_writer_no_upgrader_no_max_readers, boost::ref(*this)));
|
||||
gate1_.wait(lk, boost::bind(&upgrade_mutex::no_writer_no_upgrader_no_max_readers, this));
|
||||
count_t num_readers = (state_ & n_readers_) + 1;
|
||||
state_ &= ~n_readers_;
|
||||
state_ |= upgradable_entered_ | num_readers;
|
||||
@@ -833,7 +833,7 @@ namespace boost {
|
||||
{
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
if (!gate1_.wait_until(lk, abs_time, boost::bind(
|
||||
&upgrade_mutex::no_writer_no_upgrader_no_max_readers, boost::ref(*this))))
|
||||
&upgrade_mutex::no_writer_no_upgrader_no_max_readers, this)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -850,7 +850,7 @@ namespace boost {
|
||||
{
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
if (!gate1_.timed_wait(lk, abs_or_rel_time, boost::bind(
|
||||
&upgrade_mutex::no_writer_no_upgrader_no_max_readers, boost::ref(*this))))
|
||||
&upgrade_mutex::no_writer_no_upgrader_no_max_readers, this)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -898,7 +898,7 @@ namespace boost {
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
BOOST_ASSERT(one_or_more_readers());
|
||||
if (!gate1_.wait_until(lk, abs_time, boost::bind(
|
||||
&upgrade_mutex::no_writer_no_upgrader, boost::ref(*this))))
|
||||
&upgrade_mutex::no_writer_no_upgrader, this)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -906,7 +906,7 @@ namespace boost {
|
||||
state_ &= ~n_readers_;
|
||||
state_ |= (write_entered_ | num_readers);
|
||||
if (!gate2_.wait_until(lk, abs_time, boost::bind(
|
||||
&upgrade_mutex::no_readers, boost::ref(*this))))
|
||||
&upgrade_mutex::no_readers, this)))
|
||||
{
|
||||
++num_readers;
|
||||
state_ &= ~(write_entered_ | n_readers_);
|
||||
@@ -953,7 +953,7 @@ namespace boost {
|
||||
boost::unique_lock<mutex_t> lk(mut_);
|
||||
BOOST_ASSERT(one_or_more_readers());
|
||||
if (!gate1_.wait_until(lk, abs_time, boost::bind(
|
||||
&upgrade_mutex::no_writer_no_upgrader, boost::ref(*this))))
|
||||
&upgrade_mutex::no_writer_no_upgrader, this)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -987,7 +987,7 @@ namespace boost {
|
||||
count_t num_readers = (state_ & n_readers_) - 1;
|
||||
state_ &= ~(upgradable_entered_ | n_readers_);
|
||||
state_ |= write_entered_ | num_readers;
|
||||
gate2_.wait(lk, boost::bind(&upgrade_mutex::no_readers, boost::ref(*this)));
|
||||
gate2_.wait(lk, boost::bind(&upgrade_mutex::no_readers, this));
|
||||
}
|
||||
|
||||
inline bool upgrade_mutex::try_unlock_upgrade_and_lock()
|
||||
@@ -1017,7 +1017,7 @@ namespace boost {
|
||||
state_ &= ~(upgradable_entered_ | n_readers_);
|
||||
state_ |= (write_entered_ | num_readers);
|
||||
if (!gate2_.wait_until(lk, abs_time, boost::bind(
|
||||
&upgrade_mutex::no_readers, boost::ref(*this))))
|
||||
&upgrade_mutex::no_readers, this)))
|
||||
{
|
||||
++num_readers;
|
||||
state_ &= ~(write_entered_ | n_readers_);
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
#include <boost/thread/detail/move.hpp>
|
||||
#include <boost/thread/detail/invoke.hpp>
|
||||
|
||||
#if !defined(BOOST_THREAD_PROVIDES_INVOKE) && !defined(BOOST_THREAD_PROVIDES_INVOKE_RET)
|
||||
#include <boost/bind/bind.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/config/abi_prefix.hpp>
|
||||
|
||||
@@ -152,7 +154,7 @@ namespace boost
|
||||
{
|
||||
name_once_mutex(mutex_name,flag_address);
|
||||
}
|
||||
|
||||
|
||||
return ::boost::detail::win32::create_event(
|
||||
mutex_name,
|
||||
::boost::detail::win32::manual_reset_event,
|
||||
|
||||
Reference in New Issue
Block a user