123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068 |
- #ifndef BOOST_THREAD_SYNCHRONIZED_VALUE_HPP
- #define BOOST_THREAD_SYNCHRONIZED_VALUE_HPP
- #include <boost/thread/detail/config.hpp>
- #include <boost/thread/detail/move.hpp>
- #include <boost/thread/mutex.hpp>
- #include <boost/thread/lock_types.hpp>
- #include <boost/thread/lock_guard.hpp>
- #include <boost/thread/lock_algorithms.hpp>
- #include <boost/thread/lock_factories.hpp>
- #include <boost/thread/strict_lock.hpp>
- #include <boost/core/swap.hpp>
- #include <boost/utility/declval.hpp>
- #if ! defined(BOOST_THREAD_NO_SYNCHRONIZE)
- #include <tuple>
- #include <functional>
- #endif
- #include <boost/utility/result_of.hpp>
- #include <boost/config/abi_prefix.hpp>
- namespace boost
- {
-
- template <typename T, typename Lockable = mutex>
- class const_strict_lock_ptr
- {
- public:
- typedef T value_type;
- typedef Lockable mutex_type;
- protected:
-
- boost::unique_lock<mutex_type> lk_;
- T const& value_;
- public:
- BOOST_THREAD_MOVABLE_ONLY( const_strict_lock_ptr )
-
- const_strict_lock_ptr(T const& val, Lockable & mtx) :
- lk_(mtx), value_(val)
- {
- }
- const_strict_lock_ptr(T const& val, Lockable & mtx, adopt_lock_t tag) BOOST_NOEXCEPT :
- lk_(mtx, tag), value_(val)
- {
- }
-
- const_strict_lock_ptr(BOOST_THREAD_RV_REF(const_strict_lock_ptr) other) BOOST_NOEXCEPT
- : lk_(boost::move(BOOST_THREAD_RV(other).lk_)),value_(BOOST_THREAD_RV(other).value_)
- {
- }
- ~const_strict_lock_ptr()
- {
- }
-
- const T* operator->() const
- {
- return &value_;
- }
-
- const T& operator*() const
- {
- return value_;
- }
- };
-
- template <typename T, typename Lockable = mutex>
- class strict_lock_ptr : public const_strict_lock_ptr<T,Lockable>
- {
- typedef const_strict_lock_ptr<T,Lockable> base_type;
- public:
- BOOST_THREAD_MOVABLE_ONLY( strict_lock_ptr )
-
- strict_lock_ptr(T & val, Lockable & mtx) :
- base_type(val, mtx)
- {
- }
- strict_lock_ptr(T & val, Lockable & mtx, adopt_lock_t tag) :
- base_type(val, mtx, tag)
- {
- }
-
- strict_lock_ptr(BOOST_THREAD_RV_REF(strict_lock_ptr) other)
- : base_type(boost::move(static_cast<base_type&>(other)))
- {
- }
- ~strict_lock_ptr()
- {
- }
-
- T* operator->()
- {
- return const_cast<T*>(&this->value_);
- }
-
- T& operator*()
- {
- return const_cast<T&>(this->value_);
- }
- };
- template <typename SV>
- struct synchronized_value_strict_lock_ptr
- {
- typedef strict_lock_ptr<typename SV::value_type, typename SV::mutex_type> type;
- };
- template <typename SV>
- struct synchronized_value_strict_lock_ptr<const SV>
- {
- typedef const_strict_lock_ptr<typename SV::value_type, typename SV::mutex_type> type;
- };
-
- template <typename T, typename Lockable = mutex>
- class const_unique_lock_ptr : public unique_lock<Lockable>
- {
- typedef unique_lock<Lockable> base_type;
- public:
- typedef T value_type;
- typedef Lockable mutex_type;
- protected:
- T const& value_;
- public:
- BOOST_THREAD_MOVABLE_ONLY(const_unique_lock_ptr)
-
- const_unique_lock_ptr(T const& val, Lockable & mtx)
- : base_type(mtx), value_(val)
- {
- }
-
- const_unique_lock_ptr(T const& val, Lockable & mtx, adopt_lock_t) BOOST_NOEXCEPT
- : base_type(mtx, adopt_lock), value_(val)
- {
- }
-
- const_unique_lock_ptr(T const& val, Lockable & mtx, defer_lock_t) BOOST_NOEXCEPT
- : base_type(mtx, defer_lock), value_(val)
- {
- }
-
- const_unique_lock_ptr(T const& val, Lockable & mtx, try_to_lock_t) BOOST_NOEXCEPT
- : base_type(mtx, try_to_lock), value_(val)
- {
- }
-
- const_unique_lock_ptr(BOOST_THREAD_RV_REF(const_unique_lock_ptr) other) BOOST_NOEXCEPT
- : base_type(boost::move(static_cast<base_type&>(other))), value_(BOOST_THREAD_RV(other).value_)
- {
- }
-
- ~const_unique_lock_ptr()
- {
- }
-
- const T* operator->() const
- {
- BOOST_ASSERT (this->owns_lock());
- return &value_;
- }
-
- const T& operator*() const
- {
- BOOST_ASSERT (this->owns_lock());
- return value_;
- }
- };
-
- template <typename T, typename Lockable = mutex>
- class unique_lock_ptr : public const_unique_lock_ptr<T, Lockable>
- {
- typedef const_unique_lock_ptr<T, Lockable> base_type;
- public:
- typedef T value_type;
- typedef Lockable mutex_type;
- BOOST_THREAD_MOVABLE_ONLY(unique_lock_ptr)
-
- unique_lock_ptr(T & val, Lockable & mtx)
- : base_type(val, mtx)
- {
- }
-
- unique_lock_ptr(T & value, Lockable & mtx, adopt_lock_t) BOOST_NOEXCEPT
- : base_type(value, mtx, adopt_lock)
- {
- }
-
- unique_lock_ptr(T & value, Lockable & mtx, defer_lock_t) BOOST_NOEXCEPT
- : base_type(value, mtx, defer_lock)
- {
- }
-
- unique_lock_ptr(T & value, Lockable & mtx, try_to_lock_t) BOOST_NOEXCEPT
- : base_type(value, mtx, try_to_lock)
- {
- }
-
- unique_lock_ptr(BOOST_THREAD_RV_REF(unique_lock_ptr) other) BOOST_NOEXCEPT
- : base_type(boost::move(static_cast<base_type&>(other)))
- {
- }
- ~unique_lock_ptr()
- {
- }
-
- T* operator->()
- {
- BOOST_ASSERT (this->owns_lock());
- return const_cast<T*>(&this->value_);
- }
-
- T& operator*()
- {
- BOOST_ASSERT (this->owns_lock());
- return const_cast<T&>(this->value_);
- }
- };
- template <typename SV>
- struct synchronized_value_unique_lock_ptr
- {
- typedef unique_lock_ptr<typename SV::value_type, typename SV::mutex_type> type;
- };
- template <typename SV>
- struct synchronized_value_unique_lock_ptr<const SV>
- {
- typedef const_unique_lock_ptr<typename SV::value_type, typename SV::mutex_type> type;
- };
-
- template <typename T, typename Lockable = mutex>
- class synchronized_value
- {
- #if ! defined(BOOST_THREAD_NO_MAKE_UNIQUE_LOCKS)
- #if ! defined BOOST_NO_CXX11_VARIADIC_TEMPLATES
- template <typename ...SV>
- friend std::tuple<typename synchronized_value_strict_lock_ptr<SV>::type ...> synchronize(SV& ...sv);
- #else
- template <typename SV1, typename SV2>
- friend std::tuple<
- typename synchronized_value_strict_lock_ptr<SV1>::type,
- typename synchronized_value_strict_lock_ptr<SV2>::type
- >
- synchronize(SV1& sv1, SV2& sv2);
- template <typename SV1, typename SV2, typename SV3>
- friend std::tuple<
- typename synchronized_value_strict_lock_ptr<SV1>::type,
- typename synchronized_value_strict_lock_ptr<SV2>::type,
- typename synchronized_value_strict_lock_ptr<SV3>::type
- >
- synchronize(SV1& sv1, SV2& sv2, SV3& sv3);
- #endif
- #endif
- public:
- typedef T value_type;
- typedef Lockable mutex_type;
- private:
- T value_;
- mutable mutex_type mtx_;
- public:
-
-
- synchronized_value()
-
- : value_()
- {
- }
-
- synchronized_value(T const& other)
-
- : value_(other)
- {
- }
-
- synchronized_value(BOOST_THREAD_RV_REF(T) other)
-
- : value_(boost::move(other))
- {
- }
-
- synchronized_value(synchronized_value const& rhs)
- {
- strict_lock<mutex_type> lk(rhs.mtx_);
- value_ = rhs.value_;
- }
-
- synchronized_value(BOOST_THREAD_RV_REF(synchronized_value) other)
- {
- strict_lock<mutex_type> lk(BOOST_THREAD_RV(other).mtx_);
- value_= boost::move(BOOST_THREAD_RV(other).value_);
- }
-
-
- synchronized_value& operator=(synchronized_value const& rhs)
- {
- if(&rhs != this)
- {
-
- unique_lock<mutex_type> lk1(mtx_, defer_lock);
- unique_lock<mutex_type> lk2(rhs.mtx_, defer_lock);
- lock(lk1,lk2);
- value_ = rhs.value_;
- }
- return *this;
- }
-
- synchronized_value& operator=(value_type const& val)
- {
- {
- strict_lock<mutex_type> lk(mtx_);
- value_ = val;
- }
- return *this;
- }
-
-
- T get() const
- {
- strict_lock<mutex_type> lk(mtx_);
- return value_;
- }
-
- #if ! defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
- explicit operator T() const
- {
- return get();
- }
- #endif
-
- T const& value() const
- {
- return value_;
- }
-
- mutex_type const& mutex() const
- {
- return mtx_;
- }
-
- void swap(synchronized_value & rhs)
- {
- if (this == &rhs) {
- return;
- }
-
- unique_lock<mutex_type> lk1(mtx_, defer_lock);
- unique_lock<mutex_type> lk2(rhs.mtx_, defer_lock);
- lock(lk1,lk2);
- boost::swap(value_, rhs.value_);
- }
-
- void swap(value_type & rhs)
- {
- strict_lock<mutex_type> lk(mtx_);
- boost::swap(value_, rhs);
- }
-
- strict_lock_ptr<T,Lockable> operator->()
- {
- return BOOST_THREAD_MAKE_RV_REF((strict_lock_ptr<T,Lockable>(value_, mtx_)));
- }
-
- const_strict_lock_ptr<T,Lockable> operator->() const
- {
- return BOOST_THREAD_MAKE_RV_REF((const_strict_lock_ptr<T,Lockable>(value_, mtx_)));
- }
-
- template <typename F>
- inline
- typename boost::result_of<F(value_type&)>::type
- operator()(BOOST_THREAD_RV_REF(F) fct)
- {
- strict_lock<mutex_type> lk(mtx_);
- return fct(value_);
- }
- template <typename F>
- inline
- typename boost::result_of<F(value_type const&)>::type
- operator()(BOOST_THREAD_RV_REF(F) fct) const
- {
- strict_lock<mutex_type> lk(mtx_);
- return fct(value_);
- }
- #if defined BOOST_NO_CXX11_RVALUE_REFERENCES
- template <typename F>
- inline
- typename boost::result_of<F(value_type&)>::type
- operator()(F const & fct)
- {
- strict_lock<mutex_type> lk(mtx_);
- return fct(value_);
- }
- template <typename F>
- inline
- typename boost::result_of<F(value_type const&)>::type
- operator()(F const & fct) const
- {
- strict_lock<mutex_type> lk(mtx_);
- return fct(value_);
- }
- template <typename R>
- inline
- R operator()(R(*fct)(value_type&))
- {
- strict_lock<mutex_type> lk(mtx_);
- return fct(value_);
- }
- template <typename R>
- inline
- R operator()(R(*fct)(value_type const&)) const
- {
- strict_lock<mutex_type> lk(mtx_);
- return fct(value_);
- }
- #endif
-
- strict_lock_ptr<T,Lockable> synchronize()
- {
- return BOOST_THREAD_MAKE_RV_REF((strict_lock_ptr<T,Lockable>(value_, mtx_)));
- }
- const_strict_lock_ptr<T,Lockable> synchronize() const
- {
- return BOOST_THREAD_MAKE_RV_REF((const_strict_lock_ptr<T,Lockable>(value_, mtx_)));
- }
- unique_lock_ptr<T,Lockable> unique_synchronize()
- {
- return BOOST_THREAD_MAKE_RV_REF((unique_lock_ptr<T,Lockable>(value_, mtx_)));
- }
- const_unique_lock_ptr<T,Lockable> unique_synchronize() const
- {
- return BOOST_THREAD_MAKE_RV_REF((const_unique_lock_ptr<T,Lockable>(value_, mtx_)));
- }
- unique_lock_ptr<T,Lockable> unique_synchronize(defer_lock_t tag)
- {
- return BOOST_THREAD_MAKE_RV_REF((unique_lock_ptr<T,Lockable>(value_, mtx_, tag)));
- }
- const_unique_lock_ptr<T,Lockable> unique_synchronize(defer_lock_t tag) const
- {
- return BOOST_THREAD_MAKE_RV_REF((const_unique_lock_ptr<T,Lockable>(value_, mtx_, tag)));
- }
- unique_lock_ptr<T,Lockable> defer_synchronize() BOOST_NOEXCEPT
- {
- return BOOST_THREAD_MAKE_RV_REF((unique_lock_ptr<T,Lockable>(value_, mtx_, defer_lock)));
- }
- const_unique_lock_ptr<T,Lockable> defer_synchronize() const BOOST_NOEXCEPT
- {
- return BOOST_THREAD_MAKE_RV_REF((const_unique_lock_ptr<T,Lockable>(value_, mtx_, defer_lock)));
- }
- unique_lock_ptr<T,Lockable> try_to_synchronize() BOOST_NOEXCEPT
- {
- return BOOST_THREAD_MAKE_RV_REF((unique_lock_ptr<T,Lockable>(value_, mtx_, try_to_lock)));
- }
- const_unique_lock_ptr<T,Lockable> try_to_synchronize() const BOOST_NOEXCEPT
- {
- return BOOST_THREAD_MAKE_RV_REF((const_unique_lock_ptr<T,Lockable>(value_, mtx_, try_to_lock)));
- }
- unique_lock_ptr<T,Lockable> adopt_synchronize() BOOST_NOEXCEPT
- {
- return BOOST_THREAD_MAKE_RV_REF((unique_lock_ptr<T,Lockable>(value_, mtx_, adopt_lock)));
- }
- const_unique_lock_ptr<T,Lockable> adopt_synchronize() const BOOST_NOEXCEPT
- {
- return BOOST_THREAD_MAKE_RV_REF((const_unique_lock_ptr<T,Lockable>(value_, mtx_, adopt_lock)));
- }
- #if ! defined __IBMCPP__
- private:
- #endif
- class deref_value
- {
- private:
- friend class synchronized_value;
- boost::unique_lock<mutex_type> lk_;
- T& value_;
- explicit deref_value(synchronized_value& outer):
- lk_(outer.mtx_),value_(outer.value_)
- {}
- public:
- BOOST_THREAD_MOVABLE_ONLY(deref_value)
- deref_value(BOOST_THREAD_RV_REF(deref_value) other):
- lk_(boost::move(BOOST_THREAD_RV(other).lk_)),value_(BOOST_THREAD_RV(other).value_)
- {}
- operator T&()
- {
- return value_;
- }
- deref_value& operator=(T const& newVal)
- {
- value_=newVal;
- return *this;
- }
- };
- class const_deref_value
- {
- private:
- friend class synchronized_value;
- boost::unique_lock<mutex_type> lk_;
- const T& value_;
- explicit const_deref_value(synchronized_value const& outer):
- lk_(outer.mtx_), value_(outer.value_)
- {}
- public:
- BOOST_THREAD_MOVABLE_ONLY(const_deref_value)
- const_deref_value(BOOST_THREAD_RV_REF(const_deref_value) other):
- lk_(boost::move(BOOST_THREAD_RV(other).lk_)), value_(BOOST_THREAD_RV(other).value_)
- {}
- operator const T&()
- {
- return value_;
- }
- };
- public:
- deref_value operator*()
- {
- return BOOST_THREAD_MAKE_RV_REF(deref_value(*this));
- }
- const_deref_value operator*() const
- {
- return BOOST_THREAD_MAKE_RV_REF(const_deref_value(*this));
- }
-
-
- template <typename OStream>
- void save(OStream& os) const
- {
- strict_lock<mutex_type> lk(mtx_);
- os << value_;
- }
-
- template <typename IStream>
- void load(IStream& is) const
- {
- strict_lock<mutex_type> lk(mtx_);
- is >> value_;
- }
-
-
- bool operator==(synchronized_value const& rhs) const
- {
- unique_lock<mutex_type> lk1(mtx_, defer_lock);
- unique_lock<mutex_type> lk2(rhs.mtx_, defer_lock);
- lock(lk1,lk2);
- return value_ == rhs.value_;
- }
-
- bool operator<(synchronized_value const& rhs) const
- {
- unique_lock<mutex_type> lk1(mtx_, defer_lock);
- unique_lock<mutex_type> lk2(rhs.mtx_, defer_lock);
- lock(lk1,lk2);
- return value_ < rhs.value_;
- }
-
- bool operator>(synchronized_value const& rhs) const
- {
- unique_lock<mutex_type> lk1(mtx_, defer_lock);
- unique_lock<mutex_type> lk2(rhs.mtx_, defer_lock);
- lock(lk1,lk2);
- return value_ > rhs.value_;
- }
- bool operator<=(synchronized_value const& rhs) const
- {
- unique_lock<mutex_type> lk1(mtx_, defer_lock);
- unique_lock<mutex_type> lk2(rhs.mtx_, defer_lock);
- lock(lk1,lk2);
- return value_ <= rhs.value_;
- }
- bool operator>=(synchronized_value const& rhs) const
- {
- unique_lock<mutex_type> lk1(mtx_, defer_lock);
- unique_lock<mutex_type> lk2(rhs.mtx_, defer_lock);
- lock(lk1,lk2);
- return value_ >= rhs.value_;
- }
- bool operator==(value_type const& rhs) const
- {
- unique_lock<mutex_type> lk1(mtx_);
- return value_ == rhs;
- }
- bool operator!=(value_type const& rhs) const
- {
- unique_lock<mutex_type> lk1(mtx_);
- return value_ != rhs;
- }
- bool operator<(value_type const& rhs) const
- {
- unique_lock<mutex_type> lk1(mtx_);
- return value_ < rhs;
- }
- bool operator<=(value_type const& rhs) const
- {
- unique_lock<mutex_type> lk1(mtx_);
- return value_ <= rhs;
- }
- bool operator>(value_type const& rhs) const
- {
- unique_lock<mutex_type> lk1(mtx_);
- return value_ > rhs;
- }
- bool operator>=(value_type const& rhs) const
- {
- unique_lock<mutex_type> lk1(mtx_);
- return value_ >= rhs;
- }
- };
-
-
- template <typename T, typename L>
- inline void swap(synchronized_value<T,L> & lhs, synchronized_value<T,L> & rhs)
- {
- lhs.swap(rhs);
- }
- template <typename T, typename L>
- inline void swap(synchronized_value<T,L> & lhs, T & rhs)
- {
- lhs.swap(rhs);
- }
- template <typename T, typename L>
- inline void swap(T & lhs, synchronized_value<T,L> & rhs)
- {
- rhs.swap(lhs);
- }
-
-
- template <typename T, typename L>
- bool operator!=(synchronized_value<T,L> const&lhs, synchronized_value<T,L> const& rhs)
- {
- return ! (lhs==rhs);
- }
- template <typename T, typename L>
- bool operator==(T const& lhs, synchronized_value<T,L> const&rhs)
- {
- return rhs==lhs;
- }
- template <typename T, typename L>
- bool operator!=(T const& lhs, synchronized_value<T,L> const&rhs)
- {
- return rhs!=lhs;
- }
- template <typename T, typename L>
- bool operator<(T const& lhs, synchronized_value<T,L> const&rhs)
- {
- return rhs>=lhs;
- }
- template <typename T, typename L>
- bool operator<=(T const& lhs, synchronized_value<T,L> const&rhs)
- {
- return rhs>lhs;
- }
- template <typename T, typename L>
- bool operator>(T const& lhs, synchronized_value<T,L> const&rhs)
- {
- return rhs<=lhs;
- }
- template <typename T, typename L>
- bool operator>=(T const& lhs, synchronized_value<T,L> const&rhs)
- {
- return rhs<lhs;
- }
-
- template <typename OStream, typename T, typename L>
- inline OStream& operator<<(OStream& os, synchronized_value<T,L> const& rhs)
- {
- rhs.save(os);
- return os;
- }
- template <typename IStream, typename T, typename L>
- inline IStream& operator>>(IStream& is, synchronized_value<T,L> const& rhs)
- {
- rhs.load(is);
- return is;
- }
- #if ! defined(BOOST_THREAD_NO_SYNCHRONIZE)
- #if ! defined BOOST_NO_CXX11_VARIADIC_TEMPLATES
- template <typename ...SV>
- std::tuple<typename synchronized_value_strict_lock_ptr<SV>::type ...> synchronize(SV& ...sv)
- {
- boost::lock(sv.mtx_ ...);
- typedef std::tuple<typename synchronized_value_strict_lock_ptr<SV>::type ...> t_type;
- return t_type(typename synchronized_value_strict_lock_ptr<SV>::type(sv.value_, sv.mtx_, adopt_lock) ...);
- }
- #else
- template <typename SV1, typename SV2>
- std::tuple<
- typename synchronized_value_strict_lock_ptr<SV1>::type,
- typename synchronized_value_strict_lock_ptr<SV2>::type
- >
- synchronize(SV1& sv1, SV2& sv2)
- {
- boost::lock(sv1.mtx_, sv2.mtx_);
- typedef std::tuple<
- typename synchronized_value_strict_lock_ptr<SV1>::type,
- typename synchronized_value_strict_lock_ptr<SV2>::type
- > t_type;
- return t_type(
- typename synchronized_value_strict_lock_ptr<SV1>::type(sv1.value_, sv1.mtx_, adopt_lock),
- typename synchronized_value_strict_lock_ptr<SV2>::type(sv2.value_, sv2.mtx_, adopt_lock)
- );
- }
- template <typename SV1, typename SV2, typename SV3>
- std::tuple<
- typename synchronized_value_strict_lock_ptr<SV1>::type,
- typename synchronized_value_strict_lock_ptr<SV2>::type,
- typename synchronized_value_strict_lock_ptr<SV3>::type
- >
- synchronize(SV1& sv1, SV2& sv2, SV3& sv3)
- {
- boost::lock(sv1.mtx_, sv2.mtx_);
- typedef std::tuple<
- typename synchronized_value_strict_lock_ptr<SV1>::type,
- typename synchronized_value_strict_lock_ptr<SV2>::type,
- typename synchronized_value_strict_lock_ptr<SV3>::type
- > t_type;
- return t_type(
- typename synchronized_value_strict_lock_ptr<SV1>::type(sv1.value_, sv1.mtx_, adopt_lock),
- typename synchronized_value_strict_lock_ptr<SV2>::type(sv2.value_, sv2.mtx_, adopt_lock),
- typename synchronized_value_strict_lock_ptr<SV3>::type(sv3.value_, sv3.mtx_, adopt_lock)
- );
- }
- #endif
- #endif
- }
- #include <boost/config/abi_suffix.hpp>
- #endif
|