Mercurial > hg > vamp-build-and-test
diff DEPENDENCIES/generic/include/boost/interprocess/sync/spin/mutex.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
line wrap: on
line diff
--- a/DEPENDENCIES/generic/include/boost/interprocess/sync/spin/mutex.hpp Fri Sep 04 12:01:02 2015 +0100 +++ b/DEPENDENCIES/generic/include/boost/interprocess/sync/spin/mutex.hpp Mon Sep 07 11:12:49 2015 +0100 @@ -11,7 +11,11 @@ #ifndef BOOST_INTERPROCESS_DETAIL_SPIN_MUTEX_HPP #define BOOST_INTERPROCESS_DETAIL_SPIN_MUTEX_HPP -#if (defined _MSC_VER) && (_MSC_VER >= 1200) +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif +# +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -22,7 +26,7 @@ #include <boost/interprocess/detail/atomic.hpp> #include <boost/cstdint.hpp> #include <boost/interprocess/detail/os_thread_functions.hpp> -#include <boost/interprocess/sync/spin/wait.hpp> +#include <boost/interprocess/sync/detail/common_algorithms.hpp> namespace boost { namespace interprocess { @@ -60,18 +64,7 @@ } inline void spin_mutex::lock(void) -{ - spin_wait swait; - do{ - boost::uint32_t prev_s = ipcdetail::atomic_cas32(const_cast<boost::uint32_t*>(&m_s), 1, 0); - - if (m_s == 1 && prev_s == 0){ - break; - } - // relinquish current timeslice - swait.yield(); - }while (true); -} +{ return ipcdetail::try_based_lock(*this); } inline bool spin_mutex::try_lock(void) { @@ -80,30 +73,7 @@ } inline bool spin_mutex::timed_lock(const boost::posix_time::ptime &abs_time) -{ - if(abs_time == boost::posix_time::pos_infin){ - this->lock(); - return true; - } - //Obtain current count and target time - boost::posix_time::ptime now = microsec_clock::universal_time(); - - spin_wait swait; - do{ - if(this->try_lock()){ - break; - } - now = microsec_clock::universal_time(); - - if(now >= abs_time){ - return false; - } - // relinquish current time slice - swait.yield(); - }while (true); - - return true; -} +{ return ipcdetail::try_based_timed_lock(*this, abs_time); } inline void spin_mutex::unlock(void) { ipcdetail::atomic_cas32(const_cast<boost::uint32_t*>(&m_s), 0, 1); }