|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r85805 - in trunk/boost/sync: . detail/mutexes locks
From: andrey.semashev_at_[hidden]
Date: 2013-09-20 14:43:32
Author: andysem
Date: 2013-09-20 14:43:32 EDT (Fri, 20 Sep 2013)
New Revision: 85805
URL: http://svn.boost.org/trac/boost/changeset/85805
Log:
Extracted other lock types to fix compilation in C++03 mode.
Added:
trunk/boost/sync/locks/shared_lock.hpp (contents, props changed)
trunk/boost/sync/locks/upgrade_lock.hpp (contents, props changed)
Text files modified:
trunk/boost/sync/detail/mutexes/timed_mutex_posix.hpp | 8
trunk/boost/sync/locks.hpp | 2
trunk/boost/sync/locks/shared_lock.hpp | 275 +++++++++++++++++++++++++++++++++++++
trunk/boost/sync/locks/unique_lock.hpp | 10 +
trunk/boost/sync/locks/upgrade_lock.hpp | 295 ++++++++++++++++++++++++++++++++++++++++
5 files changed, 584 insertions(+), 6 deletions(-)
Modified: trunk/boost/sync/detail/mutexes/timed_mutex_posix.hpp
==============================================================================
--- trunk/boost/sync/detail/mutexes/timed_mutex_posix.hpp Fri Sep 20 13:40:42 2013 (r85804)
+++ trunk/boost/sync/detail/mutexes/timed_mutex_posix.hpp 2013-09-20 14:43:32 EDT (Fri, 20 Sep 2013) (r85805)
@@ -196,7 +196,7 @@
template< typename Time >
typename enable_if_c< sync::detail::time_traits< Time >::is_specialized, bool >::type timed_lock(Time const& t)
{
- return timed_lock(sync::detail::time_traits< Time >::to_sync_unit(t));
+ return priv_timed_lock(sync::detail::time_traits< Time >::to_sync_unit(t));
}
native_handle_type native_handle() BOOST_NOEXCEPT
@@ -208,12 +208,12 @@
BOOST_DELETED_FUNCTION(timed_mutex& operator= (timed_mutex const&))
private:
- bool timed_lock(sync::detail::duration dur)
+ bool priv_timed_lock(sync::detail::duration dur)
{
- return timed_lock(sync::detail::time_point::now() + dur);
+ return priv_timed_lock(sync::detail::time_point::now() + dur);
}
- bool timed_lock(sync::detail::time_point const& t)
+ bool priv_timed_lock(sync::detail::time_point const& t)
{
#if defined(BOOST_SYNC_DETAIL_PTHREAD_HAS_TIMEDLOCK)
Modified: trunk/boost/sync/locks.hpp
==============================================================================
--- trunk/boost/sync/locks.hpp Fri Sep 20 13:40:42 2013 (r85804)
+++ trunk/boost/sync/locks.hpp 2013-09-20 14:43:32 EDT (Fri, 20 Sep 2013) (r85805)
@@ -23,5 +23,7 @@
#include <boost/sync/locks/lock_guard.hpp>
#include <boost/sync/locks/shared_lock_guard.hpp>
#include <boost/sync/locks/unique_lock.hpp>
+#include <boost/sync/locks/shared_lock.hpp>
+#include <boost/sync/locks/upgrade_lock.hpp>
#endif // BOOST_SYNC_LOCKS_HPP_INCLUDED_
Added: trunk/boost/sync/locks/shared_lock.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/sync/locks/shared_lock.hpp 2013-09-20 14:43:32 EDT (Fri, 20 Sep 2013) (r85805)
@@ -0,0 +1,275 @@
+/*
+ * 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.hpp
+ *
+ * \brief This header defines a shared lock guard.
+ */
+
+#ifndef BOOST_SYNC_LOCKS_SHARED_LOCK_HPP_INCLUDED_
+#define BOOST_SYNC_LOCKS_SHARED_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/detail/system_error.hpp>
+#include <boost/sync/exceptions/lock_error.hpp>
+#include <boost/sync/locks/lock_options.hpp>
+#include <boost/sync/locks/shared_lock_fwd.hpp>
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+#include <boost/sync/locks/unique_lock_fwd.hpp>
+#include <boost/sync/locks/upgrade_lock_fwd.hpp>
+#else
+// These locks need to be defined for Boost.Move emulation
+#include <boost/sync/locks/unique_lock.hpp>
+#include <boost/sync/locks/upgrade_lock.hpp>
+#endif
+
+#include <boost/sync/detail/header.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+namespace boost {
+
+namespace sync {
+
+/*!
+ * \brief A shared lock scope guard
+ */
+template< typename Mutex >
+class shared_lock
+{
+public:
+ typedef Mutex mutex_type;
+
+private:
+ mutex_type* m_mutex;
+ bool m_is_locked;
+
+public:
+ BOOST_MOVABLE_BUT_NOT_COPYABLE(shared_lock)
+
+public:
+ shared_lock() BOOST_NOEXCEPT :
+ m_mutex(NULL), m_is_locked(false)
+ {
+ }
+
+ explicit shared_lock(mutex_type& m) :
+ m_mutex(&m), m_is_locked(false)
+ {
+ lock();
+ }
+ shared_lock(mutex_type& m, adopt_lock_t) BOOST_NOEXCEPT :
+ m_mutex(&m), m_is_locked(true)
+ {
+ }
+ shared_lock(mutex_type& m, defer_lock_t) BOOST_NOEXCEPT :
+ m_mutex(&m), m_is_locked(false)
+ {
+ }
+ shared_lock(mutex_type& m, try_to_lock_t) :
+ m_mutex(&m), m_is_locked(false)
+ {
+ try_lock();
+ }
+
+ template< typename Time >
+ shared_lock(typename enable_if_c< detail::time_traits< Time >::is_specialized, mutex_type& >::type m, Time const& t) :
+ m_mutex(&m), m_is_locked(false)
+ {
+ timed_lock(t);
+ }
+
+ shared_lock(BOOST_RV_REF(shared_lock) that) BOOST_NOEXCEPT :
+ m_mutex(that.m_mutex), m_is_locked(that.m_is_locked)
+ {
+ that.m_mutex = NULL;
+ that.m_is_locked = false;
+ }
+
+ // Conversion from unique locking
+ explicit shared_lock(BOOST_RV_REF(unique_lock< mutex_type >) that) :
+ m_mutex(that.m_mutex), m_is_locked(that.m_is_locked)
+ {
+ if (m_is_locked)
+ m_mutex->unlock_and_lock_shared();
+ that.release();
+ }
+
+ explicit shared_lock(BOOST_RV_REF(upgrade_lock< mutex_type >) that) :
+ m_mutex(that.m_mutex), m_is_locked(that.m_is_locked)
+ {
+ if (m_is_locked)
+ m_mutex->unlock_upgrade_and_lock_shared();
+ that.release();
+ }
+
+ ~shared_lock()
+ {
+ if (m_is_locked)
+ m_mutex->unlock_shared();
+ }
+
+ shared_lock& operator= (BOOST_RV_REF(shared_lock) that) BOOST_NOEXCEPT
+ {
+ swap((shared_lock&)that);
+ return *this;
+ }
+
+ shared_lock& operator= (BOOST_RV_REF(unique_lock< mutex_type >) that)
+ {
+ shared_lock temp(boost::move(that));
+ swap(temp);
+ return *this;
+ }
+
+ shared_lock& operator= (BOOST_RV_REF(upgrade_lock< mutex_type >) that)
+ {
+ shared_lock temp(boost::move(that));
+ swap(temp);
+ return *this;
+ }
+
+ void lock()
+ {
+ if (!m_mutex)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+
+ if (m_is_locked)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::resource_deadlock_would_occur, "boost shared_lock already owns the mutex"));
+
+ m_mutex->lock_shared();
+ m_is_locked = true;
+ }
+
+ bool try_lock()
+ {
+ if (!m_mutex)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+
+ if (m_is_locked)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::resource_deadlock_would_occur, "boost shared_lock already owns the mutex"));
+
+ m_is_locked = m_mutex->try_lock_shared();
+
+ return m_is_locked;
+ }
+
+ template< typename Time >
+ typename enable_if_c< detail::time_traits< Time >::is_specialized, bool >::type timed_lock(Time const& time)
+ {
+ if (!m_mutex)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+
+ if (m_is_locked)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::resource_deadlock_would_occur, "boost shared_lock already owns the mutex"));
+
+ m_is_locked = m_mutex->timed_lock_shared(time);
+
+ return m_is_locked;
+ }
+
+ template< typename Duration >
+ typename detail::enable_if_tag< Duration, detail::time_duration_tag, bool >::type try_lock_for(Duration const& rel_time)
+ {
+ if (!m_mutex)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+
+ if (m_is_locked)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::resource_deadlock_would_occur, "boost shared_lock already owns the mutex"));
+
+ m_is_locked = m_mutex->try_lock_shared_for(rel_time);
+
+ return m_is_locked;
+ }
+
+ template< typename TimePoint >
+ typename detail::enable_if_tag< TimePoint, detail::time_point_tag, bool >::type try_lock_until(TimePoint const& abs_time)
+ {
+ if (!m_mutex)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+
+ if (m_is_locked)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::resource_deadlock_would_occur, "boost shared_lock already owns the mutex"));
+
+ m_is_locked = m_mutex->try_lock_shared_until(abs_time);
+
+ return m_is_locked;
+ }
+
+ void unlock()
+ {
+ if (!m_mutex)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::operation_not_permitted, "boost shared_lock has no mutex"));
+
+ if (!m_is_locked)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::operation_not_permitted, "boost shared_lock doesn't own the mutex"));
+
+ m_mutex->unlock_shared();
+ m_is_locked = false;
+ }
+
+ BOOST_EXPLICIT_OPERATOR_BOOL()
+
+ bool operator! () const BOOST_NOEXCEPT
+ {
+ return !m_is_locked;
+ }
+
+ bool owns_lock() const BOOST_NOEXCEPT
+ {
+ return m_is_locked;
+ }
+
+ mutex_type* mutex() const BOOST_NOEXCEPT
+ {
+ return m_mutex;
+ }
+
+ mutex_type* release() BOOST_NOEXCEPT
+ {
+ mutex_type* const res = m_mutex;
+ m_mutex = NULL;
+ m_is_locked = false;
+ return res;
+ }
+
+ void swap(shared_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 Mutex >
+inline void swap(shared_lock< Mutex >& lhs, shared_lock< Mutex >& rhs) BOOST_NOEXCEPT
+{
+ lhs.swap(rhs);
+}
+
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
+
+#endif // BOOST_SYNC_LOCKS_SHARED_LOCK_HPP_INCLUDED_
Modified: trunk/boost/sync/locks/unique_lock.hpp
==============================================================================
--- trunk/boost/sync/locks/unique_lock.hpp Fri Sep 20 13:40:42 2013 (r85804)
+++ trunk/boost/sync/locks/unique_lock.hpp 2013-09-20 14:43:32 EDT (Fri, 20 Sep 2013) (r85805)
@@ -28,8 +28,14 @@
#include <boost/sync/exceptions/lock_error.hpp>
#include <boost/sync/locks/lock_options.hpp>
#include <boost/sync/locks/unique_lock_fwd.hpp>
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <boost/sync/locks/shared_lock_fwd.hpp>
#include <boost/sync/locks/upgrade_lock_fwd.hpp>
+#else
+// These locks need to be defined for Boost.Move emulation
+#include <boost/sync/locks/shared_lock.hpp>
+#include <boost/sync/locks/upgrade_lock.hpp>
+#endif
#include <boost/sync/detail/header.hpp>
@@ -170,9 +176,9 @@
return *this;
}
- unique_lock& operator= (BOOST_RV_REF(upgrade_lock< mutex_type >) other)
+ unique_lock& operator= (BOOST_RV_REF(upgrade_lock< mutex_type >) that)
{
- unique_lock temp(boost::move(other));
+ unique_lock temp(boost::move(that));
swap(temp);
return *this;
}
Added: trunk/boost/sync/locks/upgrade_lock.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/sync/locks/upgrade_lock.hpp 2013-09-20 14:43:32 EDT (Fri, 20 Sep 2013) (r85805)
@@ -0,0 +1,295 @@
+/*
+ * 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.hpp
+ *
+ * \brief This header defines an upgradeable lock guard.
+ */
+
+#ifndef BOOST_SYNC_LOCKS_UPGRADE_LOCK_HPP_INCLUDED_
+#define BOOST_SYNC_LOCKS_UPGRADE_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/detail/system_error.hpp>
+#include <boost/sync/exceptions/lock_error.hpp>
+#include <boost/sync/locks/lock_options.hpp>
+#include <boost/sync/locks/upgrade_lock_fwd.hpp>
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+#include <boost/sync/locks/unique_lock_fwd.hpp>
+#include <boost/sync/locks/shared_lock_fwd.hpp>
+#else
+// These locks need to be defined for Boost.Move emulation
+#include <boost/sync/locks/unique_lock.hpp>
+#include <boost/sync/locks/shared_lock.hpp>
+#endif
+
+#include <boost/sync/detail/header.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+namespace boost {
+
+namespace sync {
+
+/*!
+ * \brief An upgradeable lock scope guard
+ */
+template< typename Mutex >
+class upgrade_lock
+{
+public:
+ typedef Mutex mutex_type;
+
+private:
+ mutex_type* m_mutex;
+ bool m_is_locked;
+
+public:
+ BOOST_MOVABLE_BUT_NOT_COPYABLE(upgrade_lock)
+
+public:
+ upgrade_lock() BOOST_NOEXCEPT :
+ m_mutex(NULL), m_is_locked(false)
+ {
+ }
+
+ explicit upgrade_lock(mutex_type& m) :
+ m_mutex(&m), m_is_locked(false)
+ {
+ lock();
+ }
+ upgrade_lock(mutex_type& m, adopt_lock_t) BOOST_NOEXCEPT :
+ m_mutex(&m), m_is_locked(true)
+ {
+ }
+ upgrade_lock(mutex_type& m, defer_lock_t) BOOST_NOEXCEPT :
+ m_mutex(&m), m_is_locked(false)
+ {
+ }
+ upgrade_lock(mutex_type& m, try_to_lock_t) :
+ m_mutex(&m), m_is_locked(false)
+ {
+ try_lock();
+ }
+
+ template< typename Time >
+ upgrade_lock(typename enable_if_c< detail::time_traits< Time >::is_specialized, mutex_type& >::type m, Time const& t) :
+ m_mutex(&m), m_is_locked(false)
+ {
+ timed_lock(t);
+ }
+
+ upgrade_lock(BOOST_RV_REF(upgrade_lock) that) BOOST_NOEXCEPT :
+ m_mutex(that.m_mutex), m_is_locked(that.m_is_locked)
+ {
+ that.m_mutex = NULL;
+ that.m_is_locked = false;
+ }
+
+ explicit upgrade_lock(BOOST_RV_REF(unique_lock< mutex_type >) that) :
+ m_mutex(that.m_mutex), m_is_locked(that.m_is_locked)
+ {
+ if (m_is_locked)
+ m_mutex->unlock_and_lock_upgrade();
+ that.release();
+ }
+
+ // Conversion from shared lock
+ upgrade_lock(BOOST_RV_REF(shared_lock< mutex_type >) sl, try_to_lock_t) :
+ m_mutex(NULL), m_is_locked(false)
+ {
+ if (sl.owns_lock())
+ {
+ if (sl.mutex()->try_unlock_shared_and_lock_upgrade())
+ {
+ m_mutex = sl.release();
+ m_is_locked = true;
+ }
+ }
+ else
+ {
+ m_mutex = sl.release();
+ }
+ }
+
+ template< typename Time >
+ upgrade_lock(BOOST_RV_REF(shared_lock< mutex_type >) sl, Time const& t, typename enable_if_c< detail::time_traits< Time >::is_specialized, int >::type = 0) :
+ m_mutex(NULL), m_is_locked(false)
+ {
+ if (sl.owns_lock())
+ {
+ if (sl.mutex()->timed_unlock_shared_and_lock_upgrade(t))
+ {
+ m_mutex = sl.release();
+ m_is_locked = true;
+ }
+ }
+ else
+ {
+ m_mutex = sl.release();
+ }
+ }
+
+ ~upgrade_lock()
+ {
+ if (m_is_locked)
+ m_mutex->unlock_upgrade();
+ }
+
+ upgrade_lock& operator= (BOOST_RV_REF(upgrade_lock) that) BOOST_NOEXCEPT
+ {
+ swap((upgrade_lock&)that);
+ return *this;
+ }
+
+ upgrade_lock& operator= (BOOST_RV_REF(unique_lock< mutex_type >) that)
+ {
+ upgrade_lock temp(boost::move(that));
+ swap(temp);
+ return *this;
+ }
+
+ void lock()
+ {
+ if (!m_mutex)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::operation_not_permitted, "boost upgrade_lock has no mutex"));
+
+ if (m_is_locked)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::resource_deadlock_would_occur, "boost upgrade_lock already owns the mutex"));
+
+ m_mutex->lock_upgrade();
+ m_is_locked = true;
+ }
+
+ bool try_lock()
+ {
+ if (!m_mutex)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::operation_not_permitted, "boost upgrade_lock has no mutex"));
+
+ if (m_is_locked)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::resource_deadlock_would_occur, "boost upgrade_lock already owns the mutex"));
+
+ m_is_locked = m_mutex->try_lock_upgrade();
+
+ return m_is_locked;
+ }
+
+ template< typename Time >
+ typename enable_if_c< detail::time_traits< Time >::is_specialized, bool >::type timed_lock(Time const& time)
+ {
+ if (!m_mutex)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::operation_not_permitted, "boost upgrade_lock has no mutex"));
+
+ if (m_is_locked)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::resource_deadlock_would_occur, "boost upgrade_lock already owns the mutex"));
+
+ m_is_locked = m_mutex->timed_lock_upgrade(time);
+
+ return m_is_locked;
+ }
+
+ template< typename Duration >
+ typename detail::enable_if_tag< Duration, detail::time_duration_tag, bool >::type try_lock_for(Duration const& rel_time)
+ {
+ if (!m_mutex)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::operation_not_permitted, "boost upgrade_lock has no mutex"));
+
+ if (m_is_locked)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::resource_deadlock_would_occur, "boost upgrade_lock already owns the mutex"));
+
+ m_is_locked = m_mutex->try_lock_upgrade_for(rel_time);
+
+ return m_is_locked;
+ }
+
+ template< typename TimePoint >
+ typename detail::enable_if_tag< TimePoint, detail::time_point_tag, bool >::type try_lock_until(TimePoint const& abs_time)
+ {
+ if (!m_mutex)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::operation_not_permitted, "boost upgrade_lock has no mutex"));
+
+ if (m_is_locked)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::resource_deadlock_would_occur, "boost upgrade_lock already owns the mutex"));
+
+ m_is_locked = m_mutex->try_lock_upgrade_until(abs_time);
+
+ return m_is_locked;
+ }
+
+ void unlock()
+ {
+ if (!m_mutex)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::operation_not_permitted, "boost upgrade_lock has no mutex"));
+
+ if (!m_is_locked)
+ BOOST_THROW_EXCEPTION(lock_error(detail::system_namespace::errc::operation_not_permitted, "boost upgrade_lock doesn't own the mutex"));
+
+ m_mutex->unlock_upgrade();
+ m_is_locked = false;
+ }
+
+ BOOST_EXPLICIT_OPERATOR_BOOL()
+
+ bool operator! () const BOOST_NOEXCEPT
+ {
+ return !m_is_locked;
+ }
+
+ bool owns_lock() const BOOST_NOEXCEPT
+ {
+ return m_is_locked;
+ }
+
+ mutex_type* mutex() const BOOST_NOEXCEPT
+ {
+ return m_mutex;
+ }
+
+ mutex_type* release() BOOST_NOEXCEPT
+ {
+ mutex_type* const res = m_mutex;
+ m_mutex = NULL;
+ m_is_locked = false;
+ return res;
+ }
+
+ void swap(upgrade_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 Mutex >
+inline void swap(upgrade_lock< Mutex >& lhs, upgrade_lock< Mutex >& rhs) BOOST_NOEXCEPT
+{
+ lhs.swap(rhs);
+}
+
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
+
+#endif // BOOST_SYNC_LOCKS_UPGRADE_LOCK_HPP_INCLUDED_
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