$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r85607 - in trunk/boost/sync: . detail locks support
From: andrey.semashev_at_[hidden]
Date: 2013-09-08 13:11:07
Author: andysem
Date: 2013-09-08 13:11:07 EDT (Sun, 08 Sep 2013)
New Revision: 85607
URL: http://svn.boost.org/trac/boost/changeset/85607
Log:
Proceeding with Boost.Sync.
Added:
   trunk/boost/sync/detail/time_traits.hpp   (contents, props changed)
   trunk/boost/sync/detail/time_units.hpp   (contents, props changed)
   trunk/boost/sync/locks/lock_guard_fwd.hpp   (contents, props changed)
   trunk/boost/sync/locks/shared_lock_fwd.hpp   (contents, props changed)
   trunk/boost/sync/locks/shared_lock_guard_fwd.hpp   (contents, props changed)
   trunk/boost/sync/locks/unique_lock_fwd.hpp   (contents, props changed)
   trunk/boost/sync/locks/upgrade_lock_fwd.hpp   (contents, props changed)
   trunk/boost/sync/support/
   trunk/boost/sync/support/date_time.hpp   (contents, props changed)
Text files modified: 
   trunk/boost/sync/detail/config.hpp               |     8                                         
   trunk/boost/sync/detail/lockable_wrapper.hpp     |    14                                         
   trunk/boost/sync/detail/time_traits.hpp          |    60 +++++                                   
   trunk/boost/sync/detail/time_units.hpp           |   158 +++++++++++++++                         
   trunk/boost/sync/locks.hpp                       |     1                                         
   trunk/boost/sync/locks/lock_guard.hpp            |    11                                         
   trunk/boost/sync/locks/lock_guard_fwd.hpp        |    43 ++++                                    
   trunk/boost/sync/locks/shared_lock_fwd.hpp       |    43 ++++                                    
   trunk/boost/sync/locks/shared_lock_guard.hpp     |    11                                         
   trunk/boost/sync/locks/shared_lock_guard_fwd.hpp |    43 ++++                                    
   trunk/boost/sync/locks/unique_lock.hpp           |   405 ++++++++++++++++----------------------- 
   trunk/boost/sync/locks/unique_lock_fwd.hpp       |    43 ++++                                    
   trunk/boost/sync/locks/upgrade_lock_fwd.hpp      |    43 ++++                                    
   trunk/boost/sync/support/date_time.hpp           |    87 ++++++++                                
   14 files changed, 710 insertions(+), 260 deletions(-)
Modified: trunk/boost/sync/detail/config.hpp
==============================================================================
--- trunk/boost/sync/detail/config.hpp	Sun Sep  8 12:10:04 2013	(r85606)
+++ trunk/boost/sync/detail/config.hpp	2013-09-08 13:11:07 EDT (Sun, 08 Sep 2013)	(r85607)
@@ -32,15 +32,15 @@
 #endif
 
 #if defined(BOOST_SYNC_USE_PTHREAD)
-#define BOOST_SYNC_AUX_PLATFORM_PTHREAD
+#define BOOST_SYNC_DETAIL_PLATFORM_PTHREAD
 #elif defined(BOOST_SYNC_USE_WINAPI_VERSION)
-#define BOOST_SYNC_AUX_PLATFORM_WINAPI
+#define BOOST_SYNC_DETAIL_PLATFORM_WINAPI
 #else
-#define BOOST_SYNC_AUX_PLATFORM_PTHREAD
+#define BOOST_SYNC_DETAIL_PLATFORM_PTHREAD
 #endif
 
 #if defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) || defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
-#define BOOST_SYNC_AUX_NO_CXX11_INITIALIZER_LISTS
+#define BOOST_SYNC_DETAIL_NO_CXX11_INITIALIZER_LISTS
 #endif
 
 #endif // BOOST_SYNC_DETAIL_CONFIG_HPP_INCLUDED_
Modified: trunk/boost/sync/detail/lockable_wrapper.hpp
==============================================================================
--- trunk/boost/sync/detail/lockable_wrapper.hpp	Sun Sep  8 12:10:04 2013	(r85606)
+++ trunk/boost/sync/detail/lockable_wrapper.hpp	2013-09-08 13:11:07 EDT (Sun, 08 Sep 2013)	(r85607)
@@ -19,17 +19,21 @@
 #include <boost/sync/detail/config.hpp>
 #include <boost/sync/detail/header.hpp>
 
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
 namespace boost {
 
 namespace sync {
 
-namespace aux {
+namespace detail {
 
-template< typename MutexT, typename OptionT = void >
+template< typename Mutex, typename Option = void >
 struct lockable_wrapper
 {
-    typedef MutexT mutex_type;
-    typedef OptionT lock_option;
+    typedef Mutex mutex_type;
+    typedef Option lock_option;
 
     mutex_type* m_mutex;
 
@@ -38,7 +42,7 @@
     }
 };
 
-} // namespace aux
+} // namespace detail
 
 } // namespace sync
 
Added: trunk/boost/sync/detail/time_traits.hpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/boost/sync/detail/time_traits.hpp	2013-09-08 13:11:07 EDT (Sun, 08 Sep 2013)	(r85607)
@@ -0,0 +1,60 @@
+/*
+ * 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)
+ *
+ * (C) Copyright 2012-2013 Vicente J. Botet Escriba
+ * (C) Copyright 2013 Andrey Semashev
+ */
+/*!
+ * \file   time_traits.hpp
+ *
+ * \brief  This header is the Boost.Sync library implementation, see the library documentation
+ *         at http://www.boost.org/doc/libs/release/libs/sync/doc/html/index.html.
+ */
+
+#ifndef BOOST_SYNC_DETAIL_TIME_TRAITS_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_TIME_TRAITS_HPP_INCLUDED_
+
+#include <boost/sync/detail/config.hpp>
+#include <boost/sync/detail/header.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+namespace boost {
+
+namespace sync {
+
+namespace detail {
+
+struct time_point_tag {};
+struct time_duration_tag {};
+
+template< typename T, typename Void = void >
+struct time_traits
+{
+    static BOOST_CONSTEXPR_OR_CONST bool is_specialized = false;
+};
+
+template< typename T, typename Tag, typename R >
+struct enable_if_tag
+{
+};
+
+template< typename T, typename R >
+struct enable_if_tag< T, typename time_traits< T >::tag, R >
+{
+    typedef R type;
+};
+
+} // namespace detail
+
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
+
+#endif // BOOST_SYNC_DETAIL_TIME_TRAITS_HPP_INCLUDED_
Added: trunk/boost/sync/detail/time_units.hpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/boost/sync/detail/time_units.hpp	2013-09-08 13:11:07 EDT (Sun, 08 Sep 2013)	(r85607)
@@ -0,0 +1,158 @@
+/*
+ *          Copyright Andrey Semashev 2013.
+ * 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)
+ */
+/*!
+ * \file   time_units.hpp
+ *
+ * \brief  This header is the Boost.Sync library implementation, see the library documentation
+ *         at http://www.boost.org/doc/libs/release/libs/sync/doc/html/index.html.
+ */
+
+#ifndef BOOST_SYNC_DETAIL_TIME_UNITS_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_TIME_UNITS_HPP_INCLUDED_
+
+#include <time.h>
+#include <boost/cstdint.hpp>
+#include <boost/sync/detail/config.hpp>
+#include <boost/sync/detail/header.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+namespace boost {
+
+namespace sync {
+
+namespace detail {
+
+#if defined(BOOST_SYNC_DETAIL_PLATFORM_PTHREAD)
+
+class duration
+{
+public:
+    typedef int64_t native_type;
+    // The native duration is in nanoseconds
+    static BOOST_CONSTEXPR_OR_CONST uint64_t subsecond_fraction = 1000000000u;
+
+private:
+    native_type m_value;
+
+public:
+    duration() : m_value(0) {}
+    explicit duration(native_type value) : m_value(value) {}
+
+    native_type get() const { return m_value; }
+
+    duration& operator+= (duration const& that)
+    {
+        m_value += that.m_value;
+        return *this;
+    }
+    duration& operator-= (duration const& that)
+    {
+        m_value -= that.m_value;
+        return *this;
+    }
+    duration operator- () const
+    {
+        return duration(-m_value);
+    }
+
+    friend duration operator+ (duration left, duration const& right)
+    {
+        left += right;
+        return left;
+    }
+    friend duration operator- (duration left, duration const& right)
+    {
+        left -= right;
+        return left;
+    }
+};
+
+class time_point
+{
+public:
+    typedef struct ::timespec native_type;
+    // The native subsecond precision is nanoseconds
+    static BOOST_CONSTEXPR_OR_CONST uint64_t subsecond_fraction = duration::subsecond_fraction;
+
+private:
+    native_type m_value;
+
+public:
+    time_point() : m_value() {}
+    explicit time_point(time_t t, unsigned long subsecond = 0)
+    {
+        m_value.tv_sec = t;
+        m_value.tv_nsec = subsecond;
+    }
+
+    native_type const& get() const { return m_value; }
+
+    static time_point now()
+    {
+#if defined(BOOST_HAS_CLOCK_GETTIME)
+        time_point t;
+        ::clock_gettime(CLOCK_REALTIME, &t.m_value);
+        return t;
+#else
+        return time_point(::time(0));
+#endif
+    }
+
+    time_point& operator+= (duration const& dur)
+    {
+        int64_t nsec = static_cast< int64_t >(m_value.tv_nsec) + dur.get();
+        int64_t tv_nsec = nsec % duration::subsecond_fraction;
+        if (tv_nsec < 0)
+        {
+            tv_nsec += subsecond_fraction;
+            --m_value.tv_sec;
+        }
+        m_value.tv_nsec = tv_nsec;
+        m_value.tv_sec += nsec / duration::subsecond_fraction;
+    }
+    time_point& operator-= (duration const& dur)
+    {
+        return operator+= (-dur);
+    }
+
+    friend time_point operator+ (time_point left, duration const& right)
+    {
+        left += right;
+        return left;
+    }
+    friend time_point operator- (time_point left, duration const& right)
+    {
+        left -= right;
+        return left;
+    }
+
+    friend duration operator- (time_point const& left, time_point const& right)
+    {
+        int64_t seconds = static_cast< int64_t >(left.m_value.tv_sec) - static_cast< int64_t >(right.m_value.tv_sec);
+        int64_t nseconds = static_cast< int64_t >(left.m_value.tv_nsec) - static_cast< int64_t >(right.m_value.tv_nsec);
+        return duration(seconds * duration::subsecond_fraction + nseconds);
+    }
+};
+
+#elif defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
+
+// TODO
+
+#endif
+
+} // namespace detail
+
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
+
+#endif // BOOST_SYNC_DETAIL_TIME_UNITS_HPP_INCLUDED_
Modified: trunk/boost/sync/locks.hpp
==============================================================================
--- trunk/boost/sync/locks.hpp	Sun Sep  8 12:10:04 2013	(r85606)
+++ trunk/boost/sync/locks.hpp	2013-09-08 13:11:07 EDT (Sun, 08 Sep 2013)	(r85607)
@@ -22,5 +22,6 @@
 
 #include <boost/sync/locks/lock_guard.hpp>
 #include <boost/sync/locks/shared_lock_guard.hpp>
+#include <boost/sync/locks/unique_lock.hpp>
 
 #endif // BOOST_SYNC_LOCKS_HPP_INCLUDED_
Modified: trunk/boost/sync/locks/lock_guard.hpp
==============================================================================
--- trunk/boost/sync/locks/lock_guard.hpp	Sun Sep  8 12:10:04 2013	(r85606)
+++ trunk/boost/sync/locks/lock_guard.hpp	2013-09-08 13:11:07 EDT (Sun, 08 Sep 2013)	(r85607)
@@ -23,6 +23,7 @@
 #endif
 
 #include <boost/sync/locks/lock_options.hpp>
+#include <boost/sync/locks/lock_guard_fwd.hpp>
 
 #include <boost/sync/detail/header.hpp>
 
@@ -33,14 +34,14 @@
 /*!
  * \brief A unique lock scope guard
  */
-template< typename MutexT >
+template< typename Mutex >
 class lock_guard
 {
-private:
-    MutexT& m_mutex;
-
 public:
-    typedef MutexT mutex_type;
+    typedef Mutex mutex_type;
+
+private:
+    mutex_type& m_mutex;
 
 public:
     explicit lock_guard(mutex_type& m) : m_mutex(m)
Added: trunk/boost/sync/locks/lock_guard_fwd.hpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/boost/sync/locks/lock_guard_fwd.hpp	2013-09-08 13:11:07 EDT (Sun, 08 Sep 2013)	(r85607)
@@ -0,0 +1,43 @@
+/*
+ * 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)
+ *
+ * (C) Copyright 2007 Anthony Williams
+ * (C) Copyright 2011-2012 Vicente J. Botet Escriba
+ * (C) Copyright 2013 Andrey Semashev
+ */
+/*!
+ * \file   locks/lock_guard_fwd.hpp
+ *
+ * \brief  This header declares an exclusive lock guard.
+ */
+
+#ifndef BOOST_SYNC_LOCKS_LOCK_GUARD_FWD_HPP_INCLUDED_
+#define BOOST_SYNC_LOCKS_LOCK_GUARD_FWD_HPP_INCLUDED_
+
+#include <boost/sync/detail/config.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+#include <boost/sync/detail/header.hpp>
+
+namespace boost {
+
+namespace sync {
+
+/*!
+ * \brief A unique lock scope guard
+ */
+template< typename Mutex >
+class lock_guard;
+
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
+
+#endif // BOOST_SYNC_LOCKS_LOCK_GUARD_FWD_HPP_INCLUDED_
Added: trunk/boost/sync/locks/shared_lock_fwd.hpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/boost/sync/locks/shared_lock_fwd.hpp	2013-09-08 13:11:07 EDT (Sun, 08 Sep 2013)	(r85607)
@@ -0,0 +1,43 @@
+/*
+ * 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)
+ *
+ * (C) Copyright 2007 Anthony Williams
+ * (C) Copyright 2011-2012 Vicente J. Botet Escriba
+ * (C) Copyright 2013 Andrey Semashev
+ */
+/*!
+ * \file   locks/shared_lock_fwd.hpp
+ *
+ * \brief  This header declares a shared lock guard.
+ */
+
+#ifndef BOOST_SYNC_LOCKS_SHARED_LOCK_FWD_HPP_INCLUDED_
+#define BOOST_SYNC_LOCKS_SHARED_LOCK_FWD_HPP_INCLUDED_
+
+#include <boost/sync/detail/config.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+#include <boost/sync/detail/header.hpp>
+
+namespace boost {
+
+namespace sync {
+
+/*!
+ * \brief A unique lock scope guard
+ */
+template< typename Mutex >
+class shared_lock;
+
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
+
+#endif // BOOST_SYNC_LOCKS_SHARED_LOCK_FWD_HPP_INCLUDED_
Modified: trunk/boost/sync/locks/shared_lock_guard.hpp
==============================================================================
--- trunk/boost/sync/locks/shared_lock_guard.hpp	Sun Sep  8 12:10:04 2013	(r85606)
+++ trunk/boost/sync/locks/shared_lock_guard.hpp	2013-09-08 13:11:07 EDT (Sun, 08 Sep 2013)	(r85607)
@@ -22,6 +22,7 @@
 #endif
 
 #include <boost/sync/locks/lock_options.hpp>
+#include <boost/sync/locks/shared_lock_guard_fwd.hpp>
 
 #include <boost/sync/detail/header.hpp>
 
@@ -32,14 +33,14 @@
 /*!
  * \brief A shared lock scope guard
  */
-template< typename MutexT >
+template< typename Mutex >
 class shared_lock_guard
 {
-private:
-    MutexT& m_mutex;
-
 public:
-    typedef MutexT mutex_type;
+    typedef Mutex mutex_type;
+
+private:
+    mutex_type& m_mutex;
 
 public:
     explicit shared_lock_guard(mutex_type& m) : m_mutex(m)
Added: trunk/boost/sync/locks/shared_lock_guard_fwd.hpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/boost/sync/locks/shared_lock_guard_fwd.hpp	2013-09-08 13:11:07 EDT (Sun, 08 Sep 2013)	(r85607)
@@ -0,0 +1,43 @@
+/*
+ * 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)
+ *
+ * (C) Copyright 2007 Anthony Williams
+ * (C) Copyright 2011-2012 Vicente J. Botet Escriba
+ * (C) Copyright 2013 Andrey Semashev
+ */
+/*!
+ * \file   locks/shared_lock_guard_fwd.hpp
+ *
+ * \brief  This header declares a shared lock guard.
+ */
+
+#ifndef BOOST_SYNC_LOCKS_SHARED_LOCK_GUARD_FWD_HPP_INCLUDED_
+#define BOOST_SYNC_LOCKS_SHARED_LOCK_GUARD_FWD_HPP_INCLUDED_
+
+#include <boost/sync/detail/config.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+#include <boost/sync/detail/header.hpp>
+
+namespace boost {
+
+namespace sync {
+
+/*!
+ * \brief A shared lock scope guard
+ */
+template< typename Mutex >
+class shared_lock_guard;
+
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
+
+#endif // BOOST_SYNC_LOCKS_SHARED_LOCK_GUARD_FWD_HPP_INCLUDED_
Modified: trunk/boost/sync/locks/unique_lock.hpp
==============================================================================
--- trunk/boost/sync/locks/unique_lock.hpp	Sun Sep  8 12:10:04 2013	(r85606)
+++ trunk/boost/sync/locks/unique_lock.hpp	2013-09-08 13:11:07 EDT (Sun, 08 Sep 2013)	(r85607)
@@ -17,10 +17,17 @@
 #define BOOST_SYNC_LOCKS_UNIQUE_LOCK_HPP_INCLUDED_
 
 #include <cstddef>
+#include <boost/throw_exception.hpp>
+#include <boost/move/core.hpp>
+#include <boost/move/utility.hpp>
 #include <boost/utility/enable_if.hpp>
 #include <boost/utility/explicit_operator_bool.hpp>
 #include <boost/sync/detail/config.hpp>
+#include <boost/sync/detail/time_traits.hpp>
 #include <boost/sync/locks/lock_options.hpp>
+#include <boost/sync/locks/unique_lock_fwd.hpp>
+#include <boost/sync/locks/shared_lock_fwd.hpp>
+#include <boost/sync/locks/upgrade_lock_fwd.hpp>
 
 #include <boost/sync/detail/header.hpp>
 
@@ -35,11 +42,11 @@
 /*!
  * \brief A unique lock scope guard
  */
-template< typename MutexT >
+template< typename Mutex >
 class unique_lock
 {
 public:
-    typedef MutexT mutex_type;
+    typedef Mutex mutex_type;
 
 private:
     mutex_type* m_mutex;
@@ -50,7 +57,7 @@
     unique_lock& operator= (upgrade_lock< mutex_type >& other);
 
 public:
-    BOOST_THREAD_MOVABLE_ONLY( unique_lock)
+    BOOST_MOVABLE_BUT_NOT_COPYABLE(unique_lock)
 
     unique_lock() BOOST_NOEXCEPT :
         m_mutex(NULL), m_is_locked(false)
@@ -76,300 +83,207 @@
         try_lock();
     }
 
-    template< typename TimeT >
-    unique_lock(typename enable_if_c< aux::time_traits< TimeT >::is_supported, mutex_type& >::type m, TimeT const& t) :
+    template< typename Time >
+    unique_lock(typename enable_if_c< detail::time_traits< Time >::is_supported, mutex_type& >::type m, Time const& t) :
         m_mutex(&m), m_is_locked(false)
     {
         timed_lock(t);
     }
 
-    unique_lock(BOOST_THREAD_RV_REF(unique_lock) other) BOOST_NOEXCEPT :
-        m_mutex(BOOST_THREAD_RV(other).m_mutex), m_is_locked(BOOST_THREAD_RV(other).m_is_locked)
+    unique_lock(BOOST_RV_REF(unique_lock) that) BOOST_NOEXCEPT :
+        m_mutex(that.m_mutex), m_is_locked(that.m_is_locked)
     {
-        BOOST_THREAD_RV(other).m_is_locked = false;
-        BOOST_THREAD_RV(other).m_mutex = NULL;
+        that.m_mutex = NULL;
+        that.m_is_locked = false;
     }
 
-    BOOST_THREAD_EXPLICIT_LOCK_CONVERSION unique_lock(BOOST_THREAD_RV_REF_BEG upgrade_lock<Mutex> BOOST_THREAD_RV_REF_END other);
-
-#ifndef BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
-    //std-2014 unique_lock move-assignment should not be noexcept
-    unique_lock& operator=(BOOST_THREAD_RV_REF_BEG upgrade_lock<Mutex> BOOST_THREAD_RV_REF_END other) //BOOST_NOEXCEPT
-    {
-        unique_lock temp(::boost::move(other));
-        swap(temp);
-        return *this;
-    }
-#endif
-
-    //std-2014 unique_lock move-assignment should not be noexcept
-    unique_lock& operator=(BOOST_THREAD_RV_REF(unique_lock) other) //BOOST_NOEXCEPT
+    explicit unique_lock(BOOST_RV_REF(upgrade_lock< mutex_type >) that)
+        m_mutex(that.m_mutex), is_locked(that.m_is_locked)
     {
-        unique_lock temp(::boost::move(other));
-        swap(temp);
-        return *this;
+        if (m_is_locked)
+        {
+            m_mutex->unlock_upgrade_and_lock();
+        }
+        that.release();
     }
 
     // Conversion from upgrade lock
-    unique_lock(BOOST_THREAD_RV_REF_BEG upgrade_lock<mutex_type> BOOST_THREAD_RV_REF_END ul, try_to_lock_t) :
+    unique_lock(BOOST_RV_REF(upgrade_lock< mutex_type >) ul, try_to_lock_t) :
         m_mutex(NULL), m_is_locked(false)
     {
-        if (BOOST_THREAD_RV(ul).owns_lock())
+        if (ul.owns_lock())
         {
-            if (BOOST_THREAD_RV(ul).mutex()->try_unlock_upgrade_and_lock())
+            if (ul.mutex()->try_unlock_upgrade_and_lock())
             {
-                m_mutex = BOOST_THREAD_RV(ul).release();
+                m_mutex = ul.release();
                 m_is_locked = true;
             }
         }
         else
         {
-            m_mutex = BOOST_THREAD_RV(ul).release();
+            m_mutex = ul.release();
         }
     }
 
-#ifdef BOOST_THREAD_USES_CHRONO
-  template <class Clock, class Duration>
-  unique_lock(BOOST_THREAD_RV_REF_BEG upgrade_lock<mutex_type> BOOST_THREAD_RV_REF_END ul,
-      const chrono::time_point<Clock, Duration>& abs_time)
-  : m(0),m_is_locked(false)
-  {
-    if (BOOST_THREAD_RV(ul).owns_lock())
-    {
-      if (BOOST_THREAD_RV(ul).mutex()->try_unlock_upgrade_and_lock_until(abs_time))
-      {
-        m = BOOST_THREAD_RV(ul).release();
-        m_is_locked = true;
-      }
-    }
-    else
+    // Conversion from shared locking
+    unique_lock(BOOST_RV_REF(shared_lock< mutex_type >) sl, try_to_lock_t) :
+        m_mutex(NULL), m_is_locked(false)
     {
-      m = BOOST_THREAD_RV(ul).release();
+        if (sl.owns_lock())
+        {
+            if (sl.mutex()->try_unlock_shared_and_lock())
+            {
+                m_mutex = sl.release();
+                m_is_locked = true;
+            }
+        }
+        else
+        {
+            m_mutex = sl.release();
+        }
     }
-  }
 
-  template <class Rep, class Period>
-  unique_lock(BOOST_THREAD_RV_REF_BEG upgrade_lock<mutex_type> BOOST_THREAD_RV_REF_END ul,
-      const chrono::duration<Rep, Period>& rel_time)
-  : m(0),m_is_locked(false)
-  {
-    if (BOOST_THREAD_RV(ul).owns_lock())
-    {
-      if (BOOST_THREAD_RV(ul).mutex()->try_unlock_upgrade_and_lock_for(rel_time))
-      {
-        m = BOOST_THREAD_RV(ul).release();
-        m_is_locked = true;
-      }
-    }
-    else
+    template< typename Time >
+    unique_lock(BOOST_RV_REF(shared_lock< mutex_type >) sl, Time const& t, typename enable_if_c< detail::time_traits< Time >::is_supported, int >::type = 0) :
+        m_mutex(NULL), m_is_locked(false)
     {
-      m = BOOST_THREAD_RV(ul).release();
+        if (sl.owns_lock())
+        {
+            if (sl.mutex()->timed_unlock_shared_and_lock(t))
+            {
+                m_mutex = sl.release();
+                m_is_locked = true;
+            }
+        }
+        else
+        {
+            m_mutex = sl.release();
+        }
     }
-  }
-#endif
 
-#ifdef BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
-  // Conversion from shared locking
-  unique_lock(BOOST_THREAD_RV_REF_BEG shared_lock<mutex_type> BOOST_THREAD_RV_REF_END sl, try_to_lock_t)
-  : m(0),m_is_locked(false)
-  {
-    if (BOOST_THREAD_RV(sl).owns_lock())
-    {
-      if (BOOST_THREAD_RV(sl).mutex()->try_unlock_shared_and_lock())
-      {
-        m = BOOST_THREAD_RV(sl).release();
-        m_is_locked = true;
-      }
-    }
-    else
+    ~unique_lock()
     {
-      m = BOOST_THREAD_RV(sl).release();
+        if (m_is_locked)
+        {
+            m_mutex->unlock();
+        }
     }
-  }
 
-#ifdef BOOST_THREAD_USES_CHRONO
-  template <class Clock, class Duration>
-  unique_lock(BOOST_THREAD_RV_REF_BEG shared_lock<mutex_type> BOOST_THREAD_RV_REF_END sl,
-      const chrono::time_point<Clock, Duration>& abs_time)
-  : m(0),m_is_locked(false)
-  {
-    if (BOOST_THREAD_RV(sl).owns_lock())
+    unique_lock& operator= (BOOST_RV_REF(unique_lock) that) BOOST_NOEXCEPT
     {
-      if (BOOST_THREAD_RV(sl).mutex()->try_unlock_shared_and_lock_until(abs_time))
-      {
-        m = BOOST_THREAD_RV(sl).release();
-        m_is_locked = true;
-      }
+        swap((unique_lock&)that);
+        return *this;
     }
-    else
+
+    unique_lock& operator= (BOOST_RV_REF(upgrade_lock< mutex_type >) other)
     {
-      m = BOOST_THREAD_RV(sl).release();
+        unique_lock temp(boost::move(other));
+        swap(temp);
+        return *this;
     }
-  }
 
-  template <class Rep, class Period>
-  unique_lock(BOOST_THREAD_RV_REF_BEG shared_lock<mutex_type> BOOST_THREAD_RV_REF_END sl,
-      const chrono::duration<Rep, Period>& rel_time)
-  : m(0),m_is_locked(false)
-  {
-    if (BOOST_THREAD_RV(sl).owns_lock())
+    void lock()
     {
-      if (BOOST_THREAD_RV(sl).mutex()->try_unlock_shared_and_lock_for(rel_time))
-      {
-        m = BOOST_THREAD_RV(sl).release();
+        if (!m_mutex)
+        {
+            boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
+        }
+        if (m_is_locked)
+        {
+            boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock already owns the mutex"));
+        }
+
+        m_mutex->lock();
         m_is_locked = true;
-      }
     }
-    else
+
+    bool try_lock()
     {
-      m = BOOST_THREAD_RV(sl).release();
-    }
-  }
-#endif // BOOST_THREAD_USES_CHRONO
-#endif // BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
+        if (!m_mutex)
+        {
+            boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
+        }
+        if (m_is_locked)
+        {
+            boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock already owns the mutex"));
+        }
 
-  void swap(unique_lock& other)BOOST_NOEXCEPT
-  {
-    std::swap(m,other.m);
-    std::swap(m_is_locked,other.m_is_locked);
-  }
+        m_is_locked = m_mutex->try_lock();
 
-  ~unique_lock()
-  {
-    if (owns_lock())
-    {
-      m->unlock();
+        return m_is_locked;
     }
-  }
 
-  void lock()
-  {
-    if (m == 0)
+    template< typename Time >
+    typename enable_if_c< detail::time_traits< Time >::is_supported, bool >::type timed_lock(Time const& time)
     {
-      boost::throw_exception(
-          boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
-    }
-    if (owns_lock())
-    {
-      boost::throw_exception(
-          boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock owns already the mutex"));
-    }
-    m->lock();
-    m_is_locked = true;
-  }
+        if (!m_mutex)
+        {
+            boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
+        }
+        if (m_is_locked)
+        {
+            boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock already owns the mutex"));
+        }
 
-  bool try_lock()
-  {
-    if (m == 0)
-    {
-      boost::throw_exception(
-          boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
-    }
-    if (owns_lock())
-    {
-      boost::throw_exception(
-          boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock owns already the mutex"));
-    }
-    m_is_locked = m->try_lock();
-    return m_is_locked;
-  }
-#if defined BOOST_THREAD_USES_DATETIME
-  template<typename TimeDuration>
-  bool timed_lock(TimeDuration const& relative_time)
-  {
-    if(m==0)
-    {
-      boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
-    }
-    if(owns_lock())
-    {
-      boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock owns already the mutex"));
-    }
-    m_is_locked=m->timed_lock(relative_time);
-    return m_is_locked;
-  }
+        m_is_locked = m->timed_lock(time);
 
-  bool timed_lock(::boost::system_time const& absolute_time)
-  {
-    if(m==0)
-    {
-      boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
-    }
-    if(owns_lock())
-    {
-      boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock owns already the mutex"));
-    }
-    m_is_locked=m->timed_lock(absolute_time);
-    return m_is_locked;
-  }
-  bool timed_lock(::boost::xtime const& absolute_time)
-  {
-    if(m==0)
-    {
-      boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
-    }
-    if(owns_lock())
-    {
-      boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock owns already the mutex"));
+        return m_is_locked;
     }
-    m_is_locked=m->timed_lock(absolute_time);
-    return m_is_locked;
-  }
-#endif
-#ifdef BOOST_THREAD_USES_CHRONO
 
-  template <class Rep, class Period>
-  bool try_lock_for(const chrono::duration<Rep, Period>& rel_time)
-  {
-    if(m==0)
-    {
-      boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
-    }
-    if(owns_lock())
+    template< typename Duration >
+    typename detail::enable_if_tag< Duration, detail::time_duration_tag, bool >::type try_lock_for(Duration const& rel_time)
     {
-      boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock owns already the mutex"));
-    }
-    m_is_locked=m->try_lock_for(rel_time);
-    return m_is_locked;
-  }
-  template <class Clock, class Duration>
-  bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time)
-  {
-    if(m==0)
-    {
-      boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
-    }
-    if(owns_lock())
-    {
-      boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock owns already the mutex"));
+        if (!m_mutex)
+        {
+            boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
+        }
+        if (m_is_locked)
+        {
+            boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock already owns the mutex"));
+        }
+
+        m_is_locked = m_mutex->try_lock_for(rel_time);
+
+        return m_is_locked;
     }
-    m_is_locked=m->try_lock_until(abs_time);
-    return m_is_locked;
-  }
-#endif
 
-  void unlock()
-  {
-    if (m == 0)
+    template< typename TimePoint >
+    typename detail::enable_if_tag< Duration, detail::time_point_tag, bool >::type try_lock_until(TimePoint const& abs_time)
     {
-      boost::throw_exception(
-          boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
+        if (!m_mutex)
+        {
+            boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
+        }
+        if (m_is_locked)
+        {
+            boost::throw_exception(boost::lock_error(system::errc::resource_deadlock_would_occur, "boost unique_lock owns already the mutex"));
+        }
+
+        m_is_locked = m_mutex->try_lock_until(abs_time);
+
+        return m_is_locked;
     }
-    if (!owns_lock())
+
+    void unlock()
     {
-      boost::throw_exception(
-          boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock doesn't own the mutex"));
-    }
-    m->unlock();
-    m_is_locked = false;
-  }
+        if (!m_mutex)
+        {
+            boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock has no mutex"));
+        }
+        if (m_is_locked)
+        {
+            boost::throw_exception(boost::lock_error(system::errc::operation_not_permitted, "boost unique_lock doesn't own the mutex"));
+        }
 
+        m_mutex->unlock();
+        m_is_locked = false;
+    }
 
     BOOST_EXPLICIT_OPERATOR_BOOL()
 
-    bool operator!() const BOOST_NOEXCEPT
+    bool operator! () const BOOST_NOEXCEPT
     {
-        return !owns_lock();
+        return !m_is_locked;
     }
 
     bool owns_lock() const BOOST_NOEXCEPT
@@ -377,27 +291,36 @@
         return m_is_locked;
     }
 
-    Mutex* mutex() const BOOST_NOEXCEPT
+    mutex_type* mutex() const BOOST_NOEXCEPT
     {
         return m_mutex;
     }
 
-    Mutex* release() BOOST_NOEXCEPT
+    mutex_type* release() BOOST_NOEXCEPT
     {
-        Mutex* const res = m_mutex;
+        mutex_type* const res = m_mutex;
         m_mutex = NULL;
         m_is_locked = false;
         return res;
     }
+
+    void swap(unique_lock& that) BOOST_NOEXCEPT
+    {
+        mutex_type* const p = m_mutex;
+        m_mutex = that.m_mutex;
+        that.m_mutex = p;
+        const bool f = m_is_locked;
+        m_is_locked = that.m_is_locked;
+        that.m_is_locked = f;
+    }
 };
 
-template< typename MutexT >
-inline void swap(unique_lock< MutexT >& lhs, unique_lock< MutexT >& rhs) BOOST_NOEXCEPT
+template< typename Mutex >
+inline void swap(unique_lock< Mutex >& lhs, unique_lock< Mutex >& rhs) BOOST_NOEXCEPT
 {
     lhs.swap(rhs);
 }
 
-
 } // namespace sync
 
 } // namespace boost
Added: trunk/boost/sync/locks/unique_lock_fwd.hpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/boost/sync/locks/unique_lock_fwd.hpp	2013-09-08 13:11:07 EDT (Sun, 08 Sep 2013)	(r85607)
@@ -0,0 +1,43 @@
+/*
+ * 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)
+ *
+ * (C) Copyright 2007 Anthony Williams
+ * (C) Copyright 2011-2012 Vicente J. Botet Escriba
+ * (C) Copyright 2013 Andrey Semashev
+ */
+/*!
+ * \file   locks/unique_lock_fwd.hpp
+ *
+ * \brief  This header declares an exclusive lock guard.
+ */
+
+#ifndef BOOST_SYNC_LOCKS_UNIQUE_LOCK_FWD_HPP_INCLUDED_
+#define BOOST_SYNC_LOCKS_UNIQUE_LOCK_FWD_HPP_INCLUDED_
+
+#include <boost/sync/detail/config.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+#include <boost/sync/detail/header.hpp>
+
+namespace boost {
+
+namespace sync {
+
+/*!
+ * \brief A unique lock scope guard
+ */
+template< typename Mutex >
+class unique_lock;
+
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
+
+#endif // BOOST_SYNC_LOCKS_UNIQUE_LOCK_FWD_HPP_INCLUDED_
Added: trunk/boost/sync/locks/upgrade_lock_fwd.hpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/boost/sync/locks/upgrade_lock_fwd.hpp	2013-09-08 13:11:07 EDT (Sun, 08 Sep 2013)	(r85607)
@@ -0,0 +1,43 @@
+/*
+ * 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)
+ *
+ * (C) Copyright 2007 Anthony Williams
+ * (C) Copyright 2011-2012 Vicente J. Botet Escriba
+ * (C) Copyright 2013 Andrey Semashev
+ */
+/*!
+ * \file   locks/upgrade_lock_fwd.hpp
+ *
+ * \brief  This header declares an upgrade lock guard.
+ */
+
+#ifndef BOOST_SYNC_LOCKS_UPGRADE_LOCK_FWD_HPP_INCLUDED_
+#define BOOST_SYNC_LOCKS_UPGRADE_LOCK_FWD_HPP_INCLUDED_
+
+#include <boost/sync/detail/config.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+#include <boost/sync/detail/header.hpp>
+
+namespace boost {
+
+namespace sync {
+
+/*!
+ * \brief A unique lock scope guard
+ */
+template< typename Mutex >
+class upgrade_lock;
+
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
+
+#endif // BOOST_SYNC_LOCKS_UPGRADE_LOCK_FWD_HPP_INCLUDED_
Added: trunk/boost/sync/support/date_time.hpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/boost/sync/support/date_time.hpp	2013-09-08 13:11:07 EDT (Sun, 08 Sep 2013)	(r85607)
@@ -0,0 +1,87 @@
+/*
+ *          Copyright Andrey Semashev 2013.
+ * 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)
+ */
+/*!
+ * \file   support/date_time.hpp
+ *
+ * \brief  This header enables support for Boost.DateTime time units.
+ */
+
+#ifndef BOOST_SYNC_SUPPORT_DATE_TIME_HPP_INCLUDED_
+#define BOOST_SYNC_SUPPORT_DATE_TIME_HPP_INCLUDED_
+
+#include <ctime>
+#include <boost/cstdint.hpp>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <boost/sync/detail/config.hpp>
+#include <boost/sync/detail/time_traits.hpp>
+#include <boost/sync/detail/time_units.hpp>
+#include <boost/sync/detail/header.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+namespace boost {
+
+namespace sync {
+
+namespace detail {
+
+template< typename T >
+struct time_traits< T, typename T::_is_boost_date_time_duration >
+{
+    typedef duration_tag tag;
+
+    static BOOST_CONSTEXPR_OR_CONST bool is_specialized = true;
+
+    static duration to_sync_unit(T const& dur)
+    {
+        typedef typename T::traits_type traits_type;
+        enum
+        {
+            conversion_ratio = traits_type::ticks_per_second >= duration::subsecond_fraction ?
+                traits_type::ticks_per_second / duration::subsecond_fraction :
+                duration::subsecond_fraction / traits_type::ticks_per_second
+        };
+        return duration(traits_type::ticks_per_second >= duration::subsecond_fraction ? dur.ticks() / conversion_ratio : dur.ticks() * conversion_ratio);
+    }
+};
+
+template< typename T >
+struct time_traits< T, typename T::_is_boost_date_time_time_point >
+{
+    typedef time_point_tag tag;
+
+    static BOOST_CONSTEXPR_OR_CONST bool is_specialized = true;
+
+    static time_point to_sync_unit(T const& point)
+    {
+        typedef typename T::date_type date_type;
+        typedef typename T::time_duration_type time_duration_type;
+        time_duration_type dur = point - T(date_type(1970, 1, 1));
+
+        std::time_t seconds = dur.total_seconds();
+        uint64_t fractional_seconds = dur.fractional_seconds();
+
+        typedef typename time_duration_type::traits_type traits_type;
+        enum
+        {
+            conversion_ratio = traits_type::ticks_per_second >= time_point::subsecond_fraction ?
+                traits_type::ticks_per_second / time_point::subsecond_fraction :
+                time_point::subsecond_fraction / traits_type::ticks_per_second
+        };
+        return time_point(seconds, traits_type::ticks_per_second >= time_point::subsecond_fraction ? fractional_seconds / conversion_ratio : fractional_seconds * conversion_ratio);
+    }
+};
+
+} // namespace detail
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
+
+#endif // BOOST_SYNC_SUPPORT_DATE_TIME_HPP_INCLUDED_