summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/Boost/src/boost/thread/locks.hpp')
-rw-r--r--3rdParty/Boost/src/boost/thread/locks.hpp170
1 files changed, 147 insertions, 23 deletions
diff --git a/3rdParty/Boost/src/boost/thread/locks.hpp b/3rdParty/Boost/src/boost/thread/locks.hpp
index 3cd6f28..d23e619 100644
--- a/3rdParty/Boost/src/boost/thread/locks.hpp
+++ b/3rdParty/Boost/src/boost/thread/locks.hpp
@@ -11,6 +11,7 @@
#include <iterator>
#include <boost/thread/thread_time.hpp>
#include <boost/detail/workaround.hpp>
+#include <boost/type_traits/is_class.hpp>
#include <boost/config/abi_prefix.hpp>
@@ -27,41 +28,101 @@ namespace boost
#ifndef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES
namespace detail
{
- template<typename T>
+#define BOOST_DEFINE_HAS_MEMBER_CALLED(member_name) \
+ template<typename T, bool=boost::is_class<T>::value> \
+ struct has_member_called_##member_name \
+ { \
+ BOOST_STATIC_CONSTANT(bool, value=false); \
+ }; \
+ \
+ template<typename T> \
+ struct has_member_called_##member_name<T,true> \
+ { \
+ typedef char true_type; \
+ struct false_type \
+ { \
+ true_type dummy[2]; \
+ }; \
+ \
+ struct fallback { int member_name; }; \
+ struct derived: \
+ T, fallback \
+ { \
+ derived(); \
+ }; \
+ \
+ template<int fallback::*> struct tester; \
+ \
+ template<typename U> \
+ static false_type has_member(tester<&U::member_name>*); \
+ template<typename U> \
+ static true_type has_member(...); \
+ \
+ BOOST_STATIC_CONSTANT( \
+ bool, value=sizeof(has_member<derived>(0))==sizeof(true_type)); \
+ }
+
+ BOOST_DEFINE_HAS_MEMBER_CALLED(lock);
+ BOOST_DEFINE_HAS_MEMBER_CALLED(unlock);
+ BOOST_DEFINE_HAS_MEMBER_CALLED(try_lock);
+
+ template<typename T,bool=has_member_called_lock<T>::value >
struct has_member_lock
{
+ BOOST_STATIC_CONSTANT(bool, value=false);
+ };
+
+ template<typename T>
+ struct has_member_lock<T,true>
+ {
typedef char true_type;
struct false_type
{
true_type dummy[2];
};
+ template<typename U,typename V>
+ static true_type has_member(V (U::*)());
template<typename U>
- static true_type has_member(U*,void (U::*dummy)()=&U::lock);
- static false_type has_member(void*);
+ static false_type has_member(U);
- BOOST_STATIC_CONSTANT(bool, value=sizeof(has_member_lock<T>::has_member((T*)NULL))==sizeof(true_type));
+ BOOST_STATIC_CONSTANT(
+ bool,value=sizeof(has_member_lock<T>::has_member(&T::lock))==sizeof(true_type));
};
-
- template<typename T>
+
+ template<typename T,bool=has_member_called_unlock<T>::value >
struct has_member_unlock
{
+ BOOST_STATIC_CONSTANT(bool, value=false);
+ };
+
+ template<typename T>
+ struct has_member_unlock<T,true>
+ {
typedef char true_type;
struct false_type
{
true_type dummy[2];
};
+ template<typename U,typename V>
+ static true_type has_member(V (U::*)());
template<typename U>
- static true_type has_member(U*,void (U::*dummy)()=&U::unlock);
- static false_type has_member(void*);
+ static false_type has_member(U);
- BOOST_STATIC_CONSTANT(bool, value=sizeof(has_member_unlock<T>::has_member((T*)NULL))==sizeof(true_type));
+ BOOST_STATIC_CONSTANT(
+ bool,value=sizeof(has_member_unlock<T>::has_member(&T::unlock))==sizeof(true_type));
};
- template<typename T>
+ template<typename T,bool=has_member_called_try_lock<T>::value >
struct has_member_try_lock
{
+ BOOST_STATIC_CONSTANT(bool, value=false);
+ };
+
+ template<typename T>
+ struct has_member_try_lock<T,true>
+ {
typedef char true_type;
struct false_type
{
@@ -69,10 +130,12 @@ namespace boost
};
template<typename U>
- static true_type has_member(U*,bool (U::*dummy)()=&U::try_lock);
- static false_type has_member(void*);
+ static true_type has_member(bool (U::*)());
+ template<typename U>
+ static false_type has_member(U);
- BOOST_STATIC_CONSTANT(bool, value=sizeof(has_member_try_lock<T>::has_member((T*)NULL))==sizeof(true_type));
+ BOOST_STATIC_CONSTANT(
+ bool,value=sizeof(has_member_try_lock<T>::has_member(&T::try_lock))==sizeof(true_type));
};
}
@@ -214,7 +277,7 @@ namespace boost
unique_lock& operator=(unique_lock&);
unique_lock& operator=(upgrade_lock<Mutex>& other);
public:
-#ifdef __SUNPRO_CC
+#if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100)
unique_lock(const volatile unique_lock&);
#endif
unique_lock():
@@ -300,7 +363,7 @@ namespace boost
return detail::thread_move_t<unique_lock<Mutex> >(*this);
}
-#ifdef __SUNPRO_CC
+#if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100)
unique_lock& operator=(unique_lock<Mutex> other)
{
swap(other);
@@ -422,6 +485,18 @@ namespace boost
{
lhs.swap(rhs);
}
+
+ template<typename Mutex>
+ inline upgrade_lock<Mutex>&& move(upgrade_lock<Mutex>&& ul)
+ {
+ return static_cast<upgrade_lock<Mutex>&&>(ul);
+ }
+
+ template<typename Mutex>
+ inline upgrade_lock<Mutex>&& move(upgrade_lock<Mutex>& ul)
+ {
+ return static_cast<upgrade_lock<Mutex>&&>(ul);
+ }
#endif
template<typename Mutex>
void swap(unique_lock<Mutex>& lhs,unique_lock<Mutex>& rhs)
@@ -678,6 +753,39 @@ namespace boost
{
try_lock();
}
+#ifdef BOOST_HAS_RVALUE_REFS
+ upgrade_lock(upgrade_lock<Mutex>&& other):
+ m(other.m),is_locked(other.is_locked)
+ {
+ other.is_locked=false;
+ other.m=0;
+ }
+
+ upgrade_lock(unique_lock<Mutex>&& other):
+ m(other.m),is_locked(other.is_locked)
+ {
+ if(is_locked)
+ {
+ m->unlock_and_lock_upgrade();
+ }
+ other.is_locked=false;
+ other.m=0;
+ }
+
+ upgrade_lock& operator=(upgrade_lock<Mutex>&& other)
+ {
+ upgrade_lock temp(static_cast<upgrade_lock<Mutex>&&>(other));
+ swap(temp);
+ return *this;
+ }
+
+ upgrade_lock& operator=(unique_lock<Mutex>&& other)
+ {
+ upgrade_lock temp(static_cast<unique_lock<Mutex>&&>(other));
+ swap(temp);
+ return *this;
+ }
+#else
upgrade_lock(detail::thread_move_t<upgrade_lock<Mutex> > other):
m(other->m),is_locked(other->is_locked)
{
@@ -720,6 +828,7 @@ namespace boost
swap(temp);
return *this;
}
+#endif
void swap(upgrade_lock& other)
{
@@ -824,6 +933,20 @@ namespace boost
}
}
+#ifdef BOOST_HAS_RVALUE_REFS
+ upgrade_to_unique_lock(upgrade_to_unique_lock<Mutex>&& other):
+ source(other.source),exclusive(move(other.exclusive))
+ {
+ other.source=0;
+ }
+
+ upgrade_to_unique_lock& operator=(upgrade_to_unique_lock<Mutex>&& other)
+ {
+ upgrade_to_unique_lock temp(other);
+ swap(temp);
+ return *this;
+ }
+#else
upgrade_to_unique_lock(detail::thread_move_t<upgrade_to_unique_lock<Mutex> > other):
source(other->source),exclusive(move(other->exclusive))
{
@@ -836,6 +959,7 @@ namespace boost
swap(temp);
return *this;
}
+#endif
void swap(upgrade_to_unique_lock& other)
{
std::swap(source,other.source);
@@ -923,15 +1047,15 @@ namespace boost
return *this;
}
- void swap(try_lock_wrapper& other)
- {
- base::swap(other);
- }
void swap(detail::thread_move_t<try_lock_wrapper<Mutex> > other)
{
base::swap(*other);
}
#endif
+ void swap(try_lock_wrapper& other)
+ {
+ base::swap(other);
+ }
void lock()
{
base::lock();
@@ -1116,7 +1240,7 @@ namespace boost
{
unsigned const lock_count=2;
unsigned lock_first=0;
- while(true)
+ for(;;)
{
switch(lock_first)
{
@@ -1169,7 +1293,7 @@ namespace boost
{
unsigned const lock_count=3;
unsigned lock_first=0;
- while(true)
+ for(;;)
{
switch(lock_first)
{
@@ -1201,7 +1325,7 @@ namespace boost
{
unsigned const lock_count=4;
unsigned lock_first=0;
- while(true)
+ for(;;)
{
switch(lock_first)
{
@@ -1239,7 +1363,7 @@ namespace boost
{
unsigned const lock_count=5;
unsigned lock_first=0;
- while(true)
+ for(;;)
{
switch(lock_first)
{