Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51255 - in sandbox/synchro/boost/synchro: . lockers process queues thread
From: vicente.botet_at_[hidden]
Date: 2009-02-14 14:58:27


Author: viboes
Date: 2009-02-14 14:58:25 EST (Sat, 14 Feb 2009)
New Revision: 51255
URL: http://svn.boost.org/trac/boost/changeset/51255

Log:
Boost.Synchro V0.0.0
Adding unique_locker family
Added:
   sandbox/synchro/boost/synchro/lockers.hpp (contents, props changed)
Text files modified:
   sandbox/synchro/boost/synchro/lockable_traits.hpp | 7
   sandbox/synchro/boost/synchro/lockers/condition_locker.hpp | 33 +
   sandbox/synchro/boost/synchro/monitor.hpp | 36 +-
   sandbox/synchro/boost/synchro/process/locks.hpp | 490 +++++++++++++++++++++++++++++++++++++++
   sandbox/synchro/boost/synchro/process/mutex.hpp | 22 +
   sandbox/synchro/boost/synchro/process_synchronization_family.hpp | 1
   sandbox/synchro/boost/synchro/queues/synchro_buffer_family.hpp | 4
   sandbox/synchro/boost/synchro/thread/locks.hpp | 464 ++++++++++++++++++++++++++++++++++++
   sandbox/synchro/boost/synchro/thread/mutex.hpp | 16 +
   sandbox/synchro/boost/synchro/thread_synchronization_family.hpp | 1
   10 files changed, 1022 insertions(+), 52 deletions(-)

Modified: sandbox/synchro/boost/synchro/lockable_traits.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/lockable_traits.hpp (original)
+++ sandbox/synchro/boost/synchro/lockable_traits.hpp 2009-02-14 14:58:25 EST (Sat, 14 Feb 2009)
@@ -305,6 +305,13 @@
     typedef typename lockable_scope_traits<
                 typename scope_tag<Lockable>::type, Lockable>::upgrade_lock type;
 };
+
+template <typename Lockable>
+struct upgrade_to_unique_locker_type {
+ typedef typename lockable_scope_traits<
+ typename scope_tag<Lockable>::type, Lockable>::upgrade_to_unique_locker type;
+};
+
 //]
 
 //[lock_exception_traits

Added: sandbox/synchro/boost/synchro/lockers.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/synchro/lockers.hpp 2009-02-14 14:58:25 EST (Sat, 14 Feb 2009)
@@ -0,0 +1,86 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_SYNCHRO_LOCKERS__HPP
+#define BOOST_SYNCHRO_LOCKERS__HPP
+
+
+#include <boost/thread/locks.hpp>
+#include <boost/synchro/lockable_traits.hpp>
+
+namespace boost { namespace synchro {
+
+ struct defer_lock_t
+ {};
+ struct try_to_lock_t
+ {};
+ struct adopt_lock_t
+ {};
+ struct throw_lock_t
+ {};
+
+
+ const defer_lock_t defer_lock={};
+ const try_to_lock_t try_to_lock={};
+ const adopt_lock_t adopt_lock={};
+ const throw_lock_t throw_lock={};
+
+ template<typename Mutex, typename ScopeTag=typename scope_tag<Mutex>::type>
+ class unique_locker;
+
+ template<typename Mutex, typename ScopeTag=typename scope_tag<Mutex>::type>
+ class shared_locker;
+
+ template<typename Mutex, typename ScopeTag=typename scope_tag<Mutex>::type>
+ class upgrade_locker;
+
+ template<typename Mutex, typename ScopeTag=typename scope_tag<Mutex>::type>
+ class upgrade_to_unique_locker;
+
+#ifdef BOOST_HAS_RVALUE_REFS
+ template<typename Mutex, typename ScopeTag>
+ void swap(unique_locker<Mutex, ScopeTag>&& lhs, unique_locker<Mutex, ScopeTag>&& rhs)
+ {
+ lhs.swap(rhs);
+ }
+#else
+ template<typename Mutex, typename ScopeTag>
+ void swap(unique_locker<Mutex, ScopeTag>& lhs, unique_locker<Mutex, ScopeTag>& rhs)
+ {
+ lhs.swap(rhs);
+ }
+#endif
+
+#ifdef BOOST_HAS_RVALUE_REFS
+ template<typename Mutex, typename ScopeTag>
+ inline unique_locker<Mutex, ScopeTag>&& move(unique_locker<Mutex, ScopeTag>&& ul)
+ {
+ return ul;
+ }
+#endif
+
+ #ifdef BOOST_HAS_RVALUE_REFS
+ template<typename Mutex, typename ScopeTag>
+ void swap(shared_locker<Mutex, ScopeTag>&& lhs,shared_locker<Mutex, ScopeTag>&& rhs)
+ {
+ lhs.swap(rhs);
+ }
+#else
+ template<typename Mutex, typename ScopeTag>
+ void swap(shared_locker<Mutex, ScopeTag>& lhs,shared_locker<Mutex, ScopeTag>& rhs)
+ {
+ lhs.swap(rhs);
+ }
+#endif
+
+
+}}
+
+#endif

Modified: sandbox/synchro/boost/synchro/lockers/condition_locker.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/lockers/condition_locker.hpp (original)
+++ sandbox/synchro/boost/synchro/lockers/condition_locker.hpp 2009-02-14 14:58:25 EST (Sat, 14 Feb 2009)
@@ -12,10 +12,11 @@
 #define BOOST_SYNCHRO_CONDITION_LOCKER__HPP
 
 #include <boost/synchro/lockable_concepts.hpp>
-#include <boost/thread/condition.hpp>
-#include <boost/synchro/thread/mutex.hpp>
+//#include <boost/thread/condition.hpp>
+//#include <boost/synchro/thread/mutex.hpp>
 #include <boost/synchro/condition_backdoor.hpp>
 #include <boost/synchro/condition_safe.hpp>
+#include <boost/synchro/lockers.hpp>
 
 namespace boost { namespace synchro {
 
@@ -24,12 +25,13 @@
 template <
     typename Lockable,
     class Condition=condition_safe<typename best_condition<Lockable>::type >
+ , typename ScopeTag=typename scope_tag<Lockable>::type
>
 class condition_unique_locker
- : protected unique_lock_type<Lockable>::type
+ : protected unique_locker<Lockable,ScopeTag>
 {
     BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
- typedef typename unique_lock_type<Lockable>::type super_type;
+ typedef unique_locker<Lockable, ScopeTag> super_type;
 public:
     typedef Lockable lockable_type;
     typedef Condition condition;
@@ -68,13 +70,16 @@
 template <
     typename Lockable,
     class Condition=condition_safe<typename best_condition<Lockable>::type >
+ , typename ScopeTag=typename scope_tag<Lockable>::type
     //, class ConditionBoosted=condition_safe_boosted<typename best_condition<Lockable>::type >
>
 class condition_unique_locker
- : protected unique_lock_type<Lockable>::type
+ : protected unique_locker<Lockable, ScopeTag>
+// : protected unique_lock_type<Lockable>::type
 {
     BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
- typedef typename unique_lock_type<Lockable>::type super_type;
+ typedef unique_locker<Lockable, ScopeTag> super_type;
+ //typedef typename unique_lock_type<Lockable>::type super_type;
 public:
     typedef Lockable lockable_type;
     typedef Condition condition;
@@ -85,7 +90,8 @@
 
     condition_unique_locker(lockable_type& obj, condition &cond)
         : super_type(obj) {
- typename condition::backdoor(cond).wait(*static_cast<typename unique_lock_type<Lockable>::type*>(this)); /*< relock on condition >*/
+ typename condition::backdoor(cond).wait(*static_cast<super_type*>(this)); /*< relock on condition >*/
+ //typename condition::backdoor(cond).wait(*this); /*< relock on condition >*/
         }
     //condition_unique_locker(lockable_type& obj, condition_boosted &cond)
     // : super_type(obj) {
@@ -95,7 +101,8 @@
     template <typename Predicate>
     condition_unique_locker(lockable_type& obj, condition &cond, Predicate pred)
         : super_type(obj) {
- typename condition::backdoor(cond).wait_when(*static_cast<typename unique_lock_type<Lockable>::type*>(this), pred); /*< relock condition when predicate satisfaied>*/
+ typename condition::backdoor(cond).wait_when(*static_cast<super_type*>(this), pred); /*< relock condition when predicate satisfaied>*/
+ //typename condition::backdoor(cond).wait_when(*this, pred); /*< relock condition when predicate satisfaied>*/
         }
     //template <typename Predicate>
     //condition_unique_locker(lockable_type& obj, condition_boosted &cond, Predicate pred)
@@ -188,12 +195,14 @@
 template <
     typename Lockable,
     class Condition=condition_safe<typename best_condition_any<Lockable>::type >
+ , typename ScopeTag=typename scope_tag<Lockable>::type
     //, class ConditionBoosted=condition_safe_boosted<typename best_condition_any<Lockable>::type >
>
 class condition_shared_locker
- : protected shared_lock<Lockable> {
+ : protected shared_locker<Lockable, ScopeTag> {
+// : protected shared_lock<Lockable> {
     BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
- typedef shared_lock<Lockable> super_type;
+ typedef shared_locker<Lockable,ScopeTag> super_type;
 public:
     typedef Lockable lockable_type;
     typedef Condition condition;
@@ -294,7 +303,7 @@
 //]
 
 
-
+#if 0
 //[condition_lockable
 template <
     typename Lockable,
@@ -359,7 +368,7 @@
     friend class boost::condition_variable_any;
 };
 //]
-
+#endif
 }
 }
 #endif

Modified: sandbox/synchro/boost/synchro/monitor.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/monitor.hpp (original)
+++ sandbox/synchro/boost/synchro/monitor.hpp 2009-02-14 14:58:25 EST (Sat, 14 Feb 2009)
@@ -16,6 +16,7 @@
 #include <boost/synchro/lockable_adapter.hpp>
 #include <boost/synchro/thread/mutex.hpp>
 #include <boost/synchro/thread/shared_mutex.hpp>
+#include <boost/synchro/thread/locks.hpp>
 
 namespace boost { namespace synchro {
 
@@ -38,12 +39,13 @@
 template <
     typename Lockable=thread_mutex,
     class Condition=typename best_condition<Lockable>::type
+ , typename ScopeTag=typename scope_tag<Lockable>::type
>
 class exclusive_monitor : protected lockable_adapter<Lockable> {
     BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
 protected:
     typedef Condition condition;
- typedef condition_unique_locker<Lockable, Condition> synchronizer;
+ typedef condition_unique_locker<Lockable, Condition, ScopeTag> synchronizer;
 };
 //]
 
@@ -51,13 +53,14 @@
 template <
     typename Lockable=thread_shared_mutex,
     class Condition=condition_safe<typename best_condition_any<Lockable>::type >,
+ , typename ScopeTag=typename scope_tag<Lockable>::type
>
 class shared_monitor : protected lockable_adapter<Lockable> {
     BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
 protected:
     typedef Condition condition;
- typedef condition_unique_locker<Lockable, Condition> synchronizer;
- typedef condition_shared_locker<Lockable, Condition> shared_synchronizer;
+ typedef condition_unique_locker<Lockable, Condition, ScopeTag> synchronizer;
+ typedef condition_shared_locker<Lockable, Condition, ScopeTag> shared_synchronizer;
 };
 //]
 
@@ -66,6 +69,7 @@
 template <
     typename Lockable=thread_mutex,
     class Condition=condition_safe<typename best_condition<Lockable>::type >
+ , typename ScopeTag=typename scope_tag<Lockable>::type
     //, class ConditionBoosted=condition_safe_boosted<typename best_condition<Lockable>::type >
>
 class exclusive_monitor : protected lockable_adapter<Lockable> {
@@ -73,7 +77,7 @@
 protected:
     typedef Condition condition;
     //typedef ConditionBoosted condition_boosted;
- typedef condition_unique_locker<Lockable, Condition
+ typedef condition_unique_locker<Lockable, Condition, ScopeTag
     // , ConditionBoosted
> synchronizer;
 };
@@ -81,6 +85,7 @@
 template <
     typename Lockable=thread_shared_mutex,
     class Condition=condition_safe<typename best_condition_any<Lockable>::type >
+ , typename ScopeTag=typename scope_tag<Lockable>::type
     //, class ConditionBoosted=condition_safe_boosted<typename best_condition_any<Lockable>::type >
>
 class shared_monitor : protected lockable_adapter<Lockable> {
@@ -88,10 +93,10 @@
 protected:
     typedef Condition condition;
     //typedef ConditionBoosted condition_boosted;
- typedef condition_unique_locker<Lockable, Condition
+ typedef condition_unique_locker<Lockable, Condition, ScopeTag
         //, ConditionBoosted
> synchronizer;
- typedef condition_shared_locker<Lockable, Condition
+ typedef condition_shared_locker<Lockable, Condition, ScopeTag
         //, ConditionBoosted
> shared_synchronizer;
 };
@@ -115,21 +120,22 @@
 template <
       typename Lockable=thread_mutex
     , typename lock_tag=typename category_tag<Lockable>::type
+ , typename ScopeTag=typename scope_tag<Lockable>::type
> struct monitor;
 
-template <typename Lockable>
-struct monitor<Lockable, exclusive_lock_tag>
- : protected exclusive_monitor<Lockable>
+template <typename Lockable, typename ScopeTag>
+struct monitor<Lockable, exclusive_lock_tag, ScopeTag>
+ : protected exclusive_monitor<Lockable, ScopeTag>
 {};
 
-template <typename Lockable>
-struct monitor<Lockable, sharable_lock_tag>
- : protected shared_monitor<Lockable>
+template <typename Lockable, typename ScopeTag>
+struct monitor<Lockable, sharable_lock_tag, ScopeTag>
+ : protected shared_monitor<Lockable, ScopeTag>
 {};
 
-template <typename Lockable>
-struct monitor<Lockable, upgradable_lock_tag>
- : protected shared_monitor<Lockable>
+template <typename Lockable, typename ScopeTag>
+struct monitor<Lockable, upgradable_lock_tag, ScopeTag>
+ : protected shared_monitor<Lockable, ScopeTag>
 {};
 //]
 }

Modified: sandbox/synchro/boost/synchro/process/locks.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/process/locks.hpp (original)
+++ sandbox/synchro/boost/synchro/process/locks.hpp 2009-02-14 14:58:25 EST (Sat, 14 Feb 2009)
@@ -19,18 +19,484 @@
 namespace boost { namespace synchro {
 
 
-template <typename T>
-struct lockable_type<boost::interprocess::scoped_lock<T> > {
- typedef T type;
-};
-template <typename T>
-struct lockable_type<boost::interprocess::sharable_lock<T> > {
- typedef T type;
-};
-template <typename T>
-struct lockable_type<boost::interprocess::upgradable_lock<T> > {
- typedef T type;
-};
+ template <typename T>
+ struct lockable_type<boost::interprocess::scoped_lock<T> > {
+ typedef T type;
+ };
+ template <typename T>
+ struct lockable_type<boost::interprocess::sharable_lock<T> > {
+ typedef T type;
+ };
+ template <typename T>
+ struct lockable_type<boost::interprocess::upgradable_lock<T> > {
+ typedef T type;
+ };
+
+ template<typename Mutex>
+ class unique_locker<Mutex,multi_process_tag>: public unique_lock_type<Mutex>::type {
+ //typename scope_tag<Mutex>::type == multi_process_tag
+ private:
+ typedef Mutex lockable_type;
+ typedef multi_process_tag scope_tag_type;
+ typedef typename unique_lock_type<Mutex>::type base_type;
+ unique_locker(unique_locker&);
+ explicit unique_locker(unique_locker<Mutex, scope_tag_type>&);
+ unique_locker& operator=(unique_locker&);
+ unique_locker& operator=(unique_locker<Mutex, scope_tag_type>& other);
+ public:
+ unique_locker(): base_type()
+ {}
+
+ explicit unique_locker(Mutex& m_): base_type(m_)
+ {}
+ unique_locker(Mutex& m_,adopt_lock_t): base_type(m_, boost::interprocess::accept_ownership)
+ {}
+ unique_locker(Mutex& m_,defer_lock_t): base_type(m_, boost::interprocess::defer_lock)
+ {}
+ unique_locker(Mutex& m_,try_to_lock_t): base_type(m_, boost::interprocess::try_to_lock)
+ {}
+ template<typename TimeDuration>
+ unique_locker(Mutex& m_,TimeDuration const& target_time): base_type(m_, target_time)
+ {}
+ unique_locker(Mutex& m_,system_time const& target_time): base_type(m_, target_time)
+ {}
+ template<typename TimeDuration>
+ unique_locker(Mutex& m_,TimeDuration const& target_time, throw_lock_t)
+ : base_type(m_, defer_lock)
+ {
+ lock_for(target_time);
+ }
+ unique_locker(Mutex& m_,system_time const& target_time, throw_lock_t)
+ : base_type(m_, defer_lock)
+ {
+ lock_until(target_time);
+ }
+#ifdef BOOST_HAS_RVALUE_REFS
+ unique_locker(unique_locker&& other): base_type(other)
+ {}
+ explicit unique_locker(upgrade_locker<Mutex,scope_tag_type>&& other) : base_type(other)
+ {}
+
+ unique_locker<Mutex, scope_tag_type>&& move()
+ {
+ return static_cast<unique_locker<Mutex, scope_tag_type>&&>(*this);
+ }
+
+
+ unique_locker& operator=(unique_locker<Mutex, scope_tag_type>&& other)
+ {
+ unique_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+
+ unique_locker& operator=(upgrade_locker<Mutex>&& other)
+ {
+ unique_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+ void swap(unique_locker&& other)
+ {
+ this->base_type.swap(other);
+ }
+#else
+ unique_locker(interprocess::detail::moved_object<unique_locker<Mutex, scope_tag_type> > other)
+ : base_type(interprocess::detail::moved_object<base_type>(other.get()))
+ {}
+ unique_locker(interprocess::detail::moved_object<upgrade_locker<Mutex,scope_tag_type> > other)
+ : base_type(interprocess::detail::moved_object<upgrade_locker<Mutex,scope_tag_type> >(other.get()))
+ {}
+ // interprocess specific
+ unique_locker(interprocess::detail::moved_object<upgrade_locker<Mutex,scope_tag_type> > other
+ , try_to_lock_t)
+ : base_type(interprocess::detail::moved_object<upgrade_locker<Mutex,scope_tag_type> >(other.get())
+ , boost::interprocess::try_to_lock)
+ {}
+
+ // interprocess specific
+ unique_locker(interprocess::detail::moved_object<upgrade_locker<Mutex,scope_tag_type> > other
+ , system_time const& target_time)
+ : base_type(interprocess::detail::moved_object<upgrade_locker<Mutex,scope_tag_type> >(other.get())
+ , target_time)
+ {}
+
+ operator interprocess::detail::moved_object<unique_locker<Mutex, scope_tag_type> >()
+ {
+ return move();
+ }
+
+ interprocess::detail::moved_object<unique_locker<Mutex, scope_tag_type> > move()
+ {
+ return interprocess::detail::moved_object<unique_locker<Mutex, scope_tag_type> >(*this);
+ }
+
+ unique_locker& operator=(interprocess::detail::moved_object<unique_locker<Mutex, scope_tag_type> > other)
+ {
+ unique_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+
+ unique_locker& operator=(interprocess::detail::moved_object<upgrade_locker<Mutex, scope_tag_type> > other)
+ {
+ unique_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+ void swap(unique_locker& other)
+ {
+ this->base_type.swap(other);
+ }
+ void swap(interprocess::detail::moved_object<unique_locker<Mutex, scope_tag_type> > other)
+ {
+ this->base_type.swap(interprocess::detail::moved_object<base_type>(other.get()));
+ }
+#endif
+
+ ~unique_locker() {}
+
+ Mutex* mutex() const
+ {
+ return static_cast<Mutex*>(this->base_type.mutex());
+ }
+
+ bool is_locking(lockable_type* l) const {
+ return l==mutex();
+ } /*< strict lockers specific function >*/
+
+ bool owns_lock() const {
+ return this->owns();
+ }
+
+ template<typename TimeDuration>
+ bool try_lock_for(TimeDuration const& relative_time)
+ {
+ return this->timed_lock(relative_time);
+ }
+
+ bool try_lock_until(::boost::system_time const& absolute_time)
+ {
+ return this->timed_lock(absolute_time);
+ }
+
+ template<typename TimeDuration>
+ void lock_for(TimeDuration const& relative_time)
+ {
+ if(!try_lock_for(relative_time)) throw timeout_exception();
+ }
+
+ void lock_until(::boost::system_time const& absolute_time)
+ {
+ if(!try_lock_until(absolute_time)) throw timeout_exception();
+ }
+
+ friend class shared_locker<Mutex,scope_tag_type>;
+ friend class upgrade_locker<Mutex,scope_tag_type>;
+ };
+#if 0
+#ifdef BOOST_HAS_RVALUE_REFS
+ template<typename Mutex, typename ScopeTag>
+ void swap(unique_locker<Mutex, ScopeTag>&& lhs, unique_locker<Mutex, ScopeTag>&& rhs)
+ {
+ lhs.swap(rhs);
+ }
+#else
+ template<typename Mutex, typename ScopeTag>
+ void swap(unique_locker<Mutex, ScopeTag>& lhs, unique_locker<Mutex, ScopeTag>& rhs)
+ {
+ lhs.swap(rhs);
+ }
+#endif
+
+#ifdef BOOST_HAS_RVALUE_REFS
+ template<typename Mutex, typename ScopeTag>
+ inline unique_locker<Mutex, ScopeTag>&& move(unique_locker<Mutex, ScopeTag>&& ul)
+ {
+ return ul;
+ }
+#endif
+#endif
+ template<typename Mutex>
+ class shared_locker<Mutex,multi_process_tag>: public shared_lock_type<Mutex>::type {
+ //typename scope_tag<Mutex>::type == multi_process_tag
+ public:
+ typedef Mutex lockable_type;
+ typedef multi_process_tag scope_tag_type;
+ typedef typename shared_lock_type<Mutex>::type base_type;
+
+ private:
+ explicit shared_locker(shared_locker&);
+ shared_locker& operator=(shared_locker&);
+ public:
+ shared_locker(): base_type()
+ {}
+
+ explicit shared_locker(Mutex& m_): base_type(m_)
+ {}
+ shared_locker(Mutex& m_,adopt_lock_t): base_type(m_, boost::interprocess::accept_ownership)
+ {}
+ shared_locker(Mutex& m_,defer_lock_t): base_type(m_, boost::interprocess::defer_lock)
+ {}
+ shared_locker(Mutex& m_,try_to_lock_t): base_type(m_, boost::interprocess::try_to_lock)
+ {}
+ shared_locker(Mutex& m_,system_time const& target_time): base_type(m_, target_time)
+ {}
+ template<typename TimeDuration>
+ shared_locker(Mutex& m_,TimeDuration const& target_time): base_type(m_, boost::get_system_time()+target_time)
+ {}
+ shared_locker(Mutex& m_,system_time const& target_time,throw_lock_t)
+ : base_type(m_, boost::interprocess::defer_lock)
+ {
+ lock_until(target_time);
+ }
+ template<typename TimeDuration>
+ shared_locker(Mutex& m_,system_time const& target_time,throw_lock_t)
+ : base_type(m_, boost::interprocess::defer_lock)
+ {
+ lock_for(target_time);
+ }
+
+
+ shared_locker(interprocess::detail::moved_object<shared_locker<Mutex, scope_tag_type> > other)
+ : base_type(interprocess::detail::moved_object<base_type>(other.get()))
+ {}
+
+ shared_locker(interprocess::detail::moved_object<unique_locker<Mutex, scope_tag_type> > other)
+ : base_type(interprocess::detail::moved_object<typename unique_lock_type<Mutex>::type>(other.get()))
+ {}
+
+ shared_locker(interprocess::detail::moved_object<upgrade_locker<Mutex, scope_tag_type> > other)
+ : base_type(interprocess::detail::moved_object<typename upgrade_lock_type<Mutex>::type>(other.get()))
+ {}
+
+ operator interprocess::detail::moved_object<shared_locker<Mutex,scope_tag_type> >()
+ {
+ return move();
+ }
+
+ interprocess::detail::moved_object<shared_locker<Mutex, scope_tag_type> > move()
+ {
+ return interprocess::detail::moved_object<shared_locker<Mutex, scope_tag_type> >(*this);
+ }
+
+
+ shared_locker& operator=(interprocess::detail::moved_object<shared_locker<Mutex, scope_tag_type> > other)
+ {
+ shared_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+
+ shared_locker& operator=(interprocess::detail::moved_object<unique_locker<Mutex, scope_tag_type> > other)
+ {
+ shared_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+
+ shared_locker& operator=(interprocess::detail::moved_object<upgrade_locker<Mutex, scope_tag_type> > other)
+ {
+ shared_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+
+#ifdef BOOST_HAS_RVALUE_REFS
+ void swap(shared_locker&& other)
+ {
+ this->base_type.swap(other);
+ }
+#else
+ void swap(shared_locker& other)
+ {
+ this->base_type.swap(other);
+ }
+ void swap(boost::interprocess::detail::moved_object<shared_locker<Mutex, scope_tag_type> > other)
+ {
+ this->base_type.swap(interprocess::detail::moved_object<base_type>(other.get()));
+ }
+#endif
+
+ Mutex* mutex() const
+ {
+ return static_cast<Mutex*>(this->base_type.mutex());
+ }
+
+ bool is_locking(lockable_type* l) const {
+ return l==mutex();
+ } /*< strict lockers specific function >*/
+
+ bool owns_lock() const {
+ return this->owns();
+ }
+
+ bool try_lock_until(boost::system_time const& absolute_time)
+ {
+ return this->timed_lock(absolute_time);
+ }
+ template<typename Duration>
+ bool try_lock_for(Duration const& relative_time)
+ {
+ return this->timed_lock(relative_time);
+ }
+
+ template<typename TimeDuration>
+ void lock_for(TimeDuration const& relative_time)
+ {
+ if(!try_lock_for(relative_time)) throw timeout_exception();
+ }
+
+ void lock_until(::boost::system_time const& absolute_time)
+ {
+ if(!try_lock_until(absolute_time)) throw timeout_exception();
+ }
+
+ };
+
+#if 0
+#ifdef BOOST_HAS_RVALUE_REFS
+ template<typename Mutex, typename ScopeTag>
+ void swap(shared_locker<Mutex, ScopeTag>&& lhs,shared_locker<Mutex, ScopeTag>&& rhs)
+ {
+ lhs.swap(rhs);
+ }
+#else
+ template<typename Mutex, typename ScopeTag>
+ void swap(shared_locker<Mutex, ScopeTag>& lhs,shared_locker<Mutex, ScopeTag>& rhs)
+ {
+ lhs.swap(rhs);
+ }
+#endif
+#endif
+
+ template<typename Mutex>
+ class upgrade_locker<Mutex,multi_process_tag>: public upgrade_lock_type<Mutex>::type {
+ //typename scope_tag<Mutex>::type == multi_process_tag
+ public:
+ typedef Mutex lockable_type;
+ typedef multi_process_tag scope_tag_type;
+ typedef typename upgrade_lock_type<Mutex>::type base_type;
+ private:
+ explicit upgrade_locker(upgrade_locker&);
+ upgrade_locker& operator=(upgrade_locker&);
+ public:
+ upgrade_locker(): base_type()
+ {}
+
+ explicit upgrade_locker(Mutex& m_): base_type(m_)
+ {
+ }
+ upgrade_locker(Mutex& m_,adopt_lock_t): base_type(m_, boost::interprocess::accept_ownership)
+ {}
+ upgrade_locker(Mutex& m_,defer_lock_t): base_type(m_, boost::interprocess::defer_lock)
+ {}
+ upgrade_locker(Mutex& m_,try_to_lock_t): base_type(m_, boost::interprocess::try_to_lock)
+ {}
+
+ upgrade_locker(interprocess::detail::moved_object<upgrade_locker<Mutex, scope_tag_type> > other)
+ : base_type(interprocess::detail::moved_object<base_type>(other.get()))
+ {}
+
+ upgrade_locker(interprocess::detail::moved_object<unique_locker<Mutex, scope_tag_type> > other)
+ : base_type(interprocess::detail::moved_object<typename unique_lock_type<Mutex>::type>(other.get()))
+ {}
+
+ operator interprocess::detail::moved_object<upgrade_locker<Mutex, scope_tag_type> >()
+ {
+ return move();
+ }
+
+ interprocess::detail::moved_object<upgrade_locker<Mutex, scope_tag_type> > move()
+ {
+ return interprocess::detail::moved_object<upgrade_locker<Mutex, scope_tag_type> >(*this);
+ }
+
+ upgrade_locker& operator=(interprocess::detail::moved_object<upgrade_locker<Mutex, scope_tag_type> > other)
+ {
+ upgrade_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+
+ upgrade_locker& operator=(interprocess::detail::moved_object<unique_locker<Mutex, scope_tag_type> > other)
+ {
+ upgrade_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+
+ void swap(upgrade_locker& other)
+ {
+ this->base_type.swap(other);
+ }
+
+ ~upgrade_locker()
+ {}
+
+ Mutex* mutex() const
+ {
+ return static_cast<Mutex*>(this->base_type.mutex());
+ }
+
+ bool is_locking(lockable_type* l) const {
+ return l==mutex();
+ } /*< strict lockers specific function >*/
+
+ bool owns_lock() const {
+ return this->owns();
+ }
+
+ friend class shared_locker<Mutex, scope_tag_type>;
+ friend class unique_locker<Mutex, scope_tag_type>;
+ };
+
+
+ template<typename Mutex>
+ class upgrade_to_unique_locker<Mutex,multi_process_tag>: public upgrade_to_unique_locker_type<Mutex>::type {
+ //typename scope_tag<Mutex>::type == multi_process_tag
+ public:
+ typedef Mutex lockable_type;
+ typedef multi_process_tag scope_tag_type;
+ typedef typename upgrade_to_unique_locker_type<Mutex>::type base_type;
+ private:
+ explicit upgrade_to_unique_locker(upgrade_to_unique_locker&);
+ upgrade_to_unique_locker& operator=(upgrade_to_unique_locker&);
+ public:
+ explicit upgrade_to_unique_locker(upgrade_locker<Mutex>& m_): base_type(m_)
+ {}
+ ~upgrade_to_unique_locker()
+ {}
+
+ upgrade_to_unique_locker(interprocess::detail::moved_object<upgrade_to_unique_locker<Mutex, scope_tag_type> > other)
+ : base_type(interprocess::detail::moved_object<base_type>(other.get()))
+ {}
+
+ upgrade_to_unique_locker& operator=(interprocess::detail::moved_object<upgrade_to_unique_locker<Mutex, scope_tag_type> > other)
+ {
+ upgrade_to_unique_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+ void swap(upgrade_to_unique_locker& other)
+ {
+ this->base_type.swap(other);
+ }
+
+ Mutex* mutex() const
+ {
+ return static_cast<Mutex*>(this->base_type.mutex());
+ }
+
+ bool is_locking(lockable_type* l) const {
+ return l==mutex();
+ } /*< strict lockers specific function >*/
+
+ bool owns_lock() const {
+ return this->owns();
+ }
+
+ };
 
 }
 }

Modified: sandbox/synchro/boost/synchro/process/mutex.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/process/mutex.hpp (original)
+++ sandbox/synchro/boost/synchro/process/mutex.hpp 2009-02-14 14:58:25 EST (Sat, 14 Feb 2009)
@@ -56,6 +56,28 @@
     //{return timed_lock_shared(abs_time);}
 
 };
+
+
+template <>
+struct unique_lock_type<interprocess_mutex> {
+ typedef boost::interprocess::scoped_lock<boost::interprocess::interprocess_mutex> type;
+};
+
+template <>
+struct shared_lock_type<interprocess_mutex> {
+ typedef boost::interprocess::sharable_lock<boost::interprocess::interprocess_mutex> type;
+};
+
+template <>
+struct upgrade_lock_type<interprocess_mutex> {
+ typedef boost::interprocess::upgradable_lock<boost::interprocess::interprocess_mutex> type;
+};
+#if 0
+template <>
+struct upgrade_to_unique_locker_type<interprocess_mutex> {
+ typedef boost::interprocess::upgrade_to_unique_lock<boost::interprocess::interprocess_mutex> type;
+};
+#endif
 #if 0
 typedef boost::interprocess::interprocess_mutex interprocess_mutex;
 

Modified: sandbox/synchro/boost/synchro/process_synchronization_family.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/process_synchronization_family.hpp (original)
+++ sandbox/synchro/boost/synchro/process_synchronization_family.hpp 2009-02-14 14:58:25 EST (Sat, 14 Feb 2009)
@@ -14,6 +14,7 @@
 #include <boost/synchro/process/mutex.hpp>
 #include <boost/synchro/process/recursive_mutex.hpp>
 #include <boost/synchro/process/upgradable_mutex.hpp>
+#include <boost/synchro/process/locks.hpp>
 #include <boost/interprocess/sync/interprocess_condition.hpp>
 
 namespace boost {

Modified: sandbox/synchro/boost/synchro/queues/synchro_buffer_family.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/queues/synchro_buffer_family.hpp (original)
+++ sandbox/synchro/boost/synchro/queues/synchro_buffer_family.hpp 2009-02-14 14:58:25 EST (Sat, 14 Feb 2009)
@@ -15,6 +15,7 @@
 //#include <boost/thread/mutex.hpp>
 //#include <boost/thread/condition_variable.hpp>
 #include <boost/synchro/lockable_traits.hpp>
+#include <boost/synchro/lockers.hpp>
 
 namespace boost { namespace synchro {
 #if 0
@@ -70,7 +71,8 @@
 {
     typedef typename Sync::mutex_type mutex_type;
     typedef typename Sync::condition_type condition_type;
- typedef typename unique_lock_type<mutex_type>::type unique_lock_type;
+ //typedef typename unique_lock_type<mutex_type>::type unique_lock_type;
+ typedef unique_locker<mutex_type> unique_lock_type;
     mutex_type mtx_;
     condition_type not_full_;
     condition_type not_empty_;

Modified: sandbox/synchro/boost/synchro/thread/locks.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/thread/locks.hpp (original)
+++ sandbox/synchro/boost/synchro/thread/locks.hpp 2009-02-14 14:58:25 EST (Sat, 14 Feb 2009)
@@ -14,22 +14,462 @@
 
 #include <boost/thread/locks.hpp>
 #include <boost/synchro/lockable_traits.hpp>
+#include <boost/synchro/lockers.hpp>
+
 
 namespace boost { namespace synchro {
 
-template <typename T>
-struct lockable_type<boost::unique_lock<T> > {
- typedef T type;
-};
-template <typename T>
-struct lockable_type<boost::shared_lock<T> > {
- typedef T type;
-};
-template <typename T>
-struct lockable_type<boost::upgrade_lock<T> > {
- typedef T type;
-};
+ template <typename T>
+ struct lockable_type<boost::unique_lock<T> > {
+ typedef T type;
+ };
+ template <typename T>
+ struct lockable_type<boost::shared_lock<T> > {
+ typedef T type;
+ };
+ template <typename T>
+ struct lockable_type<boost::upgrade_lock<T> > {
+ typedef T type;
+ };
+
+ template <typename T>
+ struct lockable_type<boost::upgrade_to_unique_lock<T> > {
+ typedef T type;
+ };
+
+
+ template<typename Mutex>
+ class unique_locker<Mutex,multi_threaded_tag>: public unique_lock_type<Mutex>::type {
+ //typename scope_tag<Mutex>::type == multi_threaded_tag
+ private:
+ typedef Mutex lockable_type;
+ typedef multi_threaded_tag scope_tag_type;
+ typedef typename unique_lock_type<Mutex>::type base_type;
+ //unique_locker(unique_locker&);
+ explicit unique_locker(unique_locker<Mutex, scope_tag_type>&);
+ //unique_locker& operator=(unique_locker&);
+ unique_locker& operator=(unique_locker<Mutex, scope_tag_type>& other);
+ public:
+ unique_locker(): base_type()
+ {}
+
+ explicit unique_locker(Mutex& m_): base_type(m_)
+ {}
+ unique_locker(Mutex& m_,adopt_lock_t): base_type(m_, boost::adopt_lock)
+ {}
+ unique_locker(Mutex& m_,defer_lock_t): base_type(m_, boost::defer_lock)
+ {}
+ unique_locker(Mutex& m_,try_to_lock_t): base_type(m_, boost::try_to_lock)
+ {}
+ template<typename TimeDuration>
+ unique_locker(Mutex& m_,TimeDuration const& target_time): base_type(m_, target_time)
+ {}
+ unique_locker(Mutex& m_,system_time const& target_time): base_type(m_, target_time)
+ {}
+ template<typename TimeDuration>
+ unique_locker(Mutex& m_,TimeDuration const& target_time, throw_lock_t)
+ : base_type(m_, defer_lock)
+ {
+ lock_for(target_time);
+ }
+ unique_locker(Mutex& m_,system_time const& target_time, throw_lock_t)
+ : base_type(m_, defer_lock)
+ {
+ lock_until(target_time);
+ }
+#ifdef BOOST_HAS_RVALUE_REFS
+ unique_locker(unique_locker&& other): base_type(other)
+ {}
+ explicit unique_locker(upgrade_locker<Mutex,scope_tag_type>&& other) : base_type(other)
+ {}
+
+ unique_locker<Mutex, scope_tag_type>&& move()
+ {
+ return static_cast<unique_locker<Mutex, scope_tag_type>&&>(*this);
+ }
+
+
+ unique_locker& operator=(unique_locker<Mutex, scope_tag_type>&& other)
+ {
+ unique_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+
+ unique_locker& operator=(upgrade_locker<Mutex>&& other)
+ {
+ unique_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+ void swap(unique_locker&& other)
+ {
+ this->base_type.swap(other);
+ }
+#else
+ unique_locker(detail::thread_move_t<unique_locker<Mutex, scope_tag_type> > other)
+ : base_type(detail::thread_move_t<base_type>(other.t))
+ {}
+ unique_locker(detail::thread_move_t<upgrade_locker<Mutex,scope_tag_type> > other)
+ : base_type(detail::thread_move_t<upgrade_locker<Mutex,scope_tag_type> >(other.t))
+ {}
+
+ operator detail::thread_move_t<unique_locker<Mutex, scope_tag_type> >()
+ {
+ return move();
+ }
+
+ detail::thread_move_t<unique_locker<Mutex, scope_tag_type> > move()
+ {
+ return detail::thread_move_t<unique_locker<Mutex, scope_tag_type> >(*this);
+ }
+
+ unique_locker& operator=(detail::thread_move_t<unique_locker<Mutex, scope_tag_type> > other)
+ {
+ unique_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+
+ unique_locker& operator=(detail::thread_move_t<upgrade_locker<Mutex, scope_tag_type> > other)
+ {
+ unique_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+ void swap(unique_locker& other)
+ {
+ this->base_type.swap(other);
+ }
+ void swap(detail::thread_move_t<unique_locker<Mutex, scope_tag_type> > other)
+ {
+ this->base_type.swap(detail::thread_move_t<base_type>(other.t));
+ }
+#endif
+
+ ~unique_locker() {}
+
+ Mutex* mutex() const
+ {
+ return static_cast<Mutex*>(this->base_type.mutex());
+ }
+ bool is_locking(lockable_type* l) const {
+ return l==mutex();
+ } /*< strict lockers specific function >*/
+
+ template<typename TimeDuration>
+ bool try_lock_for(TimeDuration const& relative_time)
+ {
+ return this->timed_lock(relative_time);
+ }
+
+ bool try_lock_until(::boost::system_time const& absolute_time)
+ {
+ return this->timed_lock(absolute_time);
+ }
+
+ template<typename TimeDuration>
+ void lock_for(TimeDuration const& relative_time)
+ {
+ if(!try_lock_for(relative_time)) throw timeout_exception();
+ }
+
+ void lock_until(::boost::system_time const& absolute_time)
+ {
+ if(!try_lock_until(absolute_time)) throw timeout_exception();
+ }
+
+ friend class shared_locker<Mutex,scope_tag_type>;
+ friend class upgrade_locker<Mutex,scope_tag_type>;
+ };
+#if 0
+#ifdef BOOST_HAS_RVALUE_REFS
+ template<typename Mutex, typename ScopeTag>
+ void swap(unique_locker<Mutex, ScopeTag>&& lhs, unique_locker<Mutex, ScopeTag>&& rhs)
+ {
+ lhs.swap(rhs);
+ }
+#else
+ template<typename Mutex, typename ScopeTag>
+ void swap(unique_locker<Mutex, ScopeTag>& lhs, unique_locker<Mutex, ScopeTag>& rhs)
+ {
+ lhs.swap(rhs);
+ }
+#endif
+
+#ifdef BOOST_HAS_RVALUE_REFS
+ template<typename Mutex, typename ScopeTag>
+ inline unique_locker<Mutex, ScopeTag>&& move(unique_locker<Mutex, ScopeTag>&& ul)
+ {
+ return ul;
+ }
+#endif
+#endif
+ template<typename Mutex>
+ class shared_locker<Mutex,multi_threaded_tag>: public shared_lock_type<Mutex>::type {
+ //typename scope_tag<Mutex>::type == multi_threaded_tag
+ public:
+ typedef Mutex lockable_type;
+ typedef multi_threaded_tag scope_tag_type;
+ typedef typename shared_lock_type<Mutex>::type base_type;
+
+ private:
+ explicit shared_locker(shared_locker&);
+ shared_locker& operator=(shared_locker&);
+ public:
+ shared_locker(): base_type()
+ {}
+
+ explicit shared_locker(Mutex& m_): base_type(m_)
+ {}
+ shared_locker(Mutex& m_,adopt_lock_t): base_type(m_, boost::adopt_lock)
+ {}
+ shared_locker(Mutex& m_,defer_lock_t): base_type(m_, boost::defer_lock)
+ {}
+ shared_locker(Mutex& m_,try_to_lock_t): base_type(m_, boost::try_to_lock)
+ {}
+ shared_locker(Mutex& m_,system_time const& target_time): base_type(m_, target_time)
+ {}
+ template<typename TimeDuration>
+ shared_locker(Mutex& m_,TimeDuration const& target_time): base_type(m_, boost::get_system_time()+target_time)
+ {}
+ shared_locker(Mutex& m_,system_time const& target_time,throw_lock_t)
+ : base_type(m_, boost::defer_lock)
+ {
+ lock_until(target_time);
+ }
+ template<typename TimeDuration>
+ shared_locker(Mutex& m_,system_time const& target_time,throw_lock_t)
+ : base_type(m_, boost::defer_lock)
+ {
+ lock_for(target_time);
+ }
+
+
+ shared_locker(detail::thread_move_t<shared_locker<Mutex, scope_tag_type> > other)
+ : base_type(detail::thread_move_t<base_type>(other.t))
+ {}
+
+ shared_locker(detail::thread_move_t<unique_locker<Mutex, scope_tag_type> > other)
+ : base_type(detail::thread_move_t<typename unique_lock_type<Mutex>::type>(other.t))
+ {}
+
+ shared_locker(detail::thread_move_t<upgrade_locker<Mutex, scope_tag_type> > other)
+ : base_type(detail::thread_move_t<typename upgrade_lock_type<Mutex>::type>(other.t))
+ {}
+
+ operator detail::thread_move_t<shared_locker<Mutex,scope_tag_type> >()
+ {
+ return move();
+ }
+
+ detail::thread_move_t<shared_locker<Mutex, scope_tag_type> > move()
+ {
+ return detail::thread_move_t<shared_locker<Mutex, scope_tag_type> >(*this);
+ }
+
+
+ shared_locker& operator=(detail::thread_move_t<shared_locker<Mutex, scope_tag_type> > other)
+ {
+ shared_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+
+ shared_locker& operator=(detail::thread_move_t<unique_locker<Mutex, scope_tag_type> > other)
+ {
+ shared_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+
+ shared_locker& operator=(detail::thread_move_t<upgrade_locker<Mutex, scope_tag_type> > other)
+ {
+ shared_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+
+#ifdef BOOST_HAS_RVALUE_REFS
+ void swap(shared_locker&& other)
+ {
+ this->base_type.swap(other);
+ }
+#else
+ void swap(shared_locker& other)
+ {
+ this->base_type.swap(other);
+ }
+ void swap(boost::detail::thread_move_t<shared_locker<Mutex, scope_tag_type> > other)
+ {
+ this->base_type.swap(detail::thread_move_t<base_type>(other.t));
+ }
+#endif
+
+ Mutex* mutex() const
+ {
+ return static_cast<Mutex*>(this->base_type.mutex());
+ }
+
+ bool is_locking(lockable_type* l) const {
+ return l==mutex();
+ } /*< strict lockers specific function >*/
+
+ bool try_lock_until(boost::system_time const& absolute_time)
+ {
+ return this->timed_lock(absolute_time);
+ }
+ template<typename Duration>
+ bool try_lock_for(Duration const& relative_time)
+ {
+ return this->timed_lock(relative_time);
+ }
+
+ template<typename TimeDuration>
+ void lock_for(TimeDuration const& relative_time)
+ {
+ if(!try_lock_for(relative_time)) throw timeout_exception();
+ }
+
+ void lock_until(::boost::system_time const& absolute_time)
+ {
+ if(!try_lock_until(absolute_time)) throw timeout_exception();
+ }
+
+ };
+
+#if 0
+#ifdef BOOST_HAS_RVALUE_REFS
+ template<typename Mutex, typename ScopeTag>
+ void swap(shared_locker<Mutex, ScopeTag>&& lhs,shared_locker<Mutex, ScopeTag>&& rhs)
+ {
+ lhs.swap(rhs);
+ }
+#else
+ template<typename Mutex, typename ScopeTag>
+ void swap(shared_locker<Mutex, ScopeTag>& lhs,shared_locker<Mutex, ScopeTag>& rhs)
+ {
+ lhs.swap(rhs);
+ }
+#endif
+#endif
+ template<typename Mutex>
+ class upgrade_locker<Mutex,multi_threaded_tag>: public upgrade_lock_type<Mutex>::type {
+ //typename scope_tag<Mutex>::type == multi_threaded_tag
+ public:
+ typedef Mutex lockable_type;
+ typedef multi_threaded_tag scope_tag_type;
+ typedef typename upgrade_lock_type<Mutex>::type base_type;
+ private:
+ explicit upgrade_locker(upgrade_locker&);
+ upgrade_locker& operator=(upgrade_locker&);
+ public:
+ upgrade_locker(): base_type()
+ {}
+
+ explicit upgrade_locker(Mutex& m_): base_type(m_)
+ {
+ }
+ upgrade_locker(Mutex& m_,adopt_lock_t): base_type(m_, boost::adopt_lock)
+ {}
+ upgrade_locker(Mutex& m_,defer_lock_t): base_type(m_, boost::defer_lock)
+ {}
+ upgrade_locker(Mutex& m_,try_to_lock_t): base_type(m_, boost::try_to_lock)
+ {}
+
+ upgrade_locker(detail::thread_move_t<upgrade_locker<Mutex, scope_tag_type> > other)
+ : base_type(detail::thread_move_t<base_type>(other.t))
+ {}
+
+ upgrade_locker(detail::thread_move_t<unique_locker<Mutex, scope_tag_type> > other)
+ : base_type(detail::thread_move_t<typename unique_lock_type<Mutex>::type>(other.t))
+ {}
+
+ operator detail::thread_move_t<upgrade_locker<Mutex, scope_tag_type> >()
+ {
+ return move();
+ }
+
+ detail::thread_move_t<upgrade_locker<Mutex, scope_tag_type> > move()
+ {
+ return detail::thread_move_t<upgrade_locker<Mutex, scope_tag_type> >(*this);
+ }
+
+ upgrade_locker& operator=(detail::thread_move_t<upgrade_locker<Mutex, scope_tag_type> > other)
+ {
+ upgrade_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+
+ upgrade_locker& operator=(detail::thread_move_t<unique_locker<Mutex, scope_tag_type> > other)
+ {
+ upgrade_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+
+ void swap(upgrade_locker& other)
+ {
+ this->base_type.swap(other);
+ }
+
+ ~upgrade_locker()
+ {}
+
+ Mutex* mutex() const
+ {
+ return static_cast<Mutex*>(this->base_type.mutex());
+ }
+
+ bool is_locking(lockable_type* l) const {
+ return l==mutex();
+ } /*< strict lockers specific function >*/
+
+ friend class shared_locker<Mutex, scope_tag_type>;
+ friend class unique_locker<Mutex, scope_tag_type>;
+ };
+
+
+ template<typename Mutex>
+ class upgrade_to_unique_locker<Mutex,multi_threaded_tag>: public upgrade_to_unique_locker_type<Mutex>::type {
+ //typename scope_tag<Mutex>::type == multi_threaded_tag
+ public:
+ typedef Mutex lockable_type;
+ typedef multi_threaded_tag scope_tag_type;
+ typedef typename upgrade_to_unique_locker_type<Mutex>::type base_type;
+ private:
+ explicit upgrade_to_unique_locker(upgrade_to_unique_locker&);
+ upgrade_to_unique_locker& operator=(upgrade_to_unique_locker&);
+ public:
+ explicit upgrade_to_unique_locker(upgrade_locker<Mutex>& m_): base_type(m_)
+ {}
+ ~upgrade_to_unique_locker()
+ {}
+
+ upgrade_to_unique_locker(detail::thread_move_t<upgrade_to_unique_locker<Mutex, scope_tag_type> > other)
+ : base_type(detail::thread_move_t<base_type>(other.t))
+ {}
+
+ upgrade_to_unique_locker& operator=(detail::thread_move_t<upgrade_to_unique_locker<Mutex, scope_tag_type> > other)
+ {
+ upgrade_to_unique_locker temp(other);
+ swap(temp);
+ return *this;
+ }
+ void swap(upgrade_to_unique_locker& other)
+ {
+ this->base_type.swap(other);
+ }
+ Mutex* mutex() const
+ {
+ return static_cast<Mutex*>(this->base_type.mutex());
+ }
 
+ bool is_locking(lockable_type* l) const {
+ return l==mutex();
+ } /*< strict lockers specific function >*/
+ };
 
 }
 }

Modified: sandbox/synchro/boost/synchro/thread/mutex.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/thread/mutex.hpp (original)
+++ sandbox/synchro/boost/synchro/thread/mutex.hpp 2009-02-14 14:58:25 EST (Sat, 14 Feb 2009)
@@ -51,6 +51,22 @@
 };
 
 template <>
+struct shared_lock_type<thread_mutex> {
+ typedef boost::shared_lock<boost::mutex> type;
+};
+
+template <>
+struct upgrade_lock_type<thread_mutex> {
+ typedef boost::upgrade_lock<boost::mutex> type;
+};
+
+template <>
+struct upgrade_to_unique_locker_type<thread_mutex> {
+ typedef boost::upgrade_to_unique_lock<boost::mutex> type;
+};
+
+
+template <>
 struct lock_error_type<boost::mutex> {
     typedef boost::lock_error type;
 };

Modified: sandbox/synchro/boost/synchro/thread_synchronization_family.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/thread_synchronization_family.hpp (original)
+++ sandbox/synchro/boost/synchro/thread_synchronization_family.hpp 2009-02-14 14:58:25 EST (Sat, 14 Feb 2009)
@@ -14,6 +14,7 @@
 #include <boost/synchro/thread/mutex.hpp>
 #include <boost/synchro/thread/recursive_mutex.hpp>
 #include <boost/synchro/thread/shared_mutex.hpp>
+#include <boost/synchro/thread/locks.hpp>
 #include <boost/thread/condition_variable.hpp>
 
 namespace boost {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk