//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
//
#ifndef BOOST_INTERPROCESS_UPGRADABLE_LOCK_HPP
#define BOOST_INTERPROCESS_UPGRADABLE_LOCK_HPP
-#if (defined _MSC_VER) && (_MSC_VER >= 1200)
+#if defined(_MSC_VER)
# pragma once
#endif
#include <boost/interprocess/detail/type_traits.hpp>
#include <boost/interprocess/exceptions.hpp>
-#include <boost/move/move.hpp>
+#include <boost/move/utility_core.hpp>
#include <boost/interprocess/detail/posix_time_types_wrk.hpp>
//!\file
{
public:
typedef UpgradableMutex mutex_type;
- /// @cond
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
private:
typedef upgradable_lock<UpgradableMutex> this_type;
explicit upgradable_lock(scoped_lock<mutex_type>&);
typedef bool this_type::*unspecified_bool_type;
BOOST_MOVABLE_BUT_NOT_COPYABLE(upgradable_lock)
- /// @endcond
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
public:
//!Effects: Default constructs a upgradable_lock.
: mp_mutex(&m), m_locked(true)
{}
- //!Effects: m.try_lock_upgradable().
+ //!Effects: m.try_lock_upgradable().
//!Postconditions: mutex() == &m. owns() == the return value of the
//! m.try_lock_upgradable() executed within the constructor.
//!Notes: The constructor will take upgradable-ownership of the mutex
: mp_mutex(&m), m_locked(false)
{ m_locked = mp_mutex->try_lock_upgradable(); }
- //!Effects: m.timed_lock_upgradable(abs_time)
+ //!Effects: m.timed_lock_upgradable(abs_time)
//!Postconditions: mutex() == &m. owns() == the return value of the
//! m.timed_lock_upgradable() executed within the constructor.
//!Notes: The constructor will take upgradable-ownership of the mutex if it
: mp_mutex(0), m_locked(upgr.owns())
{ mp_mutex = upgr.release(); }
- //!Effects: If scop.owns(), m_.unlock_and_lock_upgradable().
+ //!Effects: If scop.owns(), m_.unlock_and_lock_upgradable().
//!Postconditions: mutex() == the value scop.mutex() had before the construction.
//! scop.mutex() == 0. owns() == scop.owns() before the constructor. After the
//! construction, scop.owns() == false.
}
//!Effects: If shar.owns() then calls try_unlock_sharable_and_lock_upgradable()
- //! on the referenced mutex.
+ //! on the referenced mutex.
//! a)if try_unlock_sharable_and_lock_upgradable() returns true then mutex()
- //! obtains the value from shar.release() and owns() is set to true.
+ //! obtains the value from shar.release() and owns() is set to true.
//! b)if try_unlock_sharable_and_lock_upgradable() returns false then shar is
//! unaffected and this upgradable_lock construction has the same
- //! effects as a default construction.
+ //! effects as a default construction.
//! c)Else shar.owns() is false. mutex() obtains the value from shar.release()
//! and owns() is set to false.
//!Notes: This construction will not block. It will try to obtain mutex
//!Notes: The sharable_lock changes from a state of not owning the mutex,
//! to owning the mutex, blocking if necessary.
void lock()
- {
+ {
if(!mp_mutex || m_locked)
throw lock_exception();
mp_mutex->lock_upgradable();
//! mutex_type does not support try_lock_upgradable(), this function will
//! fail at compile time if instantiated, but otherwise have no effect.
bool try_lock()
- {
+ {
if(!mp_mutex || m_locked)
throw lock_exception();
m_locked = mp_mutex->try_lock_upgradable();
//! timed_lock_upgradable(abs_time), this function will fail at compile
//! time if instantiated, but otherwise have no effect.
bool timed_lock(const boost::posix_time::ptime& abs_time)
- {
+ {
if(!mp_mutex || m_locked)
throw lock_exception();
m_locked = mp_mutex->timed_lock_upgradable(abs_time);
return mut;
}
- //!Effects: Swaps state with moved lock.
+ //!Effects: Swaps state with moved lock.
//!Throws: Nothing.
void swap(upgradable_lock<mutex_type> &other)
{
std::swap(m_locked, other.m_locked);
}
- /// @cond
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
private:
mutex_type *mp_mutex;
bool m_locked;
- /// @endcond
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
};
} // namespace interprocess