|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65542 - in sandbox/sync/boost/sync: . lockable_traits lockable_traits/detail null
From: vicente.botet_at_[hidden]
Date: 2010-09-23 08:13:32
Author: viboes
Date: 2010-09-23 08:13:31 EDT (Thu, 23 Sep 2010)
New Revision: 65542
URL: http://svn.boost.org/trac/boost/changeset/65542
Log:
Sync is_lockable traits
Added:
sandbox/sync/boost/sync/lockable_traits/is_lockable.hpp (contents, props changed)
Text files modified:
sandbox/sync/boost/sync/lockable_traits.hpp | 1 +
sandbox/sync/boost/sync/lockable_traits/detail/has_members.hpp | 36 ++++++++++++++++++++----------------
sandbox/sync/boost/sync/lockable_traits/is_lockable_type.hpp | 6 +++---
sandbox/sync/boost/sync/null/null_mutex.hpp | 9 +++++++++
4 files changed, 33 insertions(+), 19 deletions(-)
Modified: sandbox/sync/boost/sync/lockable_traits.hpp
==============================================================================
--- sandbox/sync/boost/sync/lockable_traits.hpp (original)
+++ sandbox/sync/boost/sync/lockable_traits.hpp 2010-09-23 08:13:31 EDT (Thu, 23 Sep 2010)
@@ -13,6 +13,7 @@
#include <boost/type_traits.hpp>
#include <boost/mpl/or.hpp>
+#include <boost/sync/lockable_traits/is_lockable.hpp>
namespace boost { namespace sync {
Modified: sandbox/sync/boost/sync/lockable_traits/detail/has_members.hpp
==============================================================================
--- sandbox/sync/boost/sync/lockable_traits/detail/has_members.hpp (original)
+++ sandbox/sync/boost/sync/lockable_traits/detail/has_members.hpp 2010-09-23 08:13:31 EDT (Thu, 23 Sep 2010)
@@ -10,9 +10,12 @@
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/type_traits/is_class.hpp>
+#include <boost/date_time/posix_time/ptime.hpp>
+#include <boost/type_traits/integral_constant.hpp>
namespace boost
{
+ namespace sync {
#ifndef BOOST_SYNC_NO_AUTO_DETECT_TYPES
#if defined(BOOST_NO_SFINAE) || \
@@ -59,9 +62,17 @@
bool, value=sizeof(has_member<derived>(0))==sizeof(true_type)); \
}
+ typedef char true_type;
+ struct false_type
+ {
+ true_type dummy[2];
+ };
+
BOOST_DEFINE_HAS_MEMBER_CALLED(lock);
BOOST_DEFINE_HAS_MEMBER_CALLED(unlock);
BOOST_DEFINE_HAS_MEMBER_CALLED(try_lock);
+ BOOST_DEFINE_HAS_MEMBER_CALLED(try_lock_until);
+ BOOST_DEFINE_HAS_MEMBER_CALLED(try_lock_for);
template<typename T,bool=has_member_called_lock<T>::value >
struct has_member_lock
@@ -72,11 +83,6 @@
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::*)());
@@ -96,11 +102,6 @@
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::*)());
@@ -120,11 +121,6 @@
template<typename T>
struct has_member_try_lock<T,true>
{
- typedef char true_type;
- struct false_type
- {
- true_type dummy[2];
- };
template<typename U>
static true_type has_member(bool (U::*)());
@@ -135,11 +131,19 @@
bool,value=sizeof(has_member_try_lock<T>::has_member(&T::try_lock))==sizeof(true_type));
};
+
+
+ template<typename T>
+ struct has_member_try_lock_until : boost::false_type {};
+
+ template<typename T>
+ struct has_member_try_lock_for : boost::false_type {};
+
}
#endif
-
+}
}
Added: sandbox/sync/boost/sync/lockable_traits/is_lockable.hpp
==============================================================================
--- (empty file)
+++ sandbox/sync/boost/sync/lockable_traits/is_lockable.hpp 2010-09-23 08:13:31 EDT (Thu, 23 Sep 2010)
@@ -0,0 +1,47 @@
+// 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 2010 Vicente J. Botet Escriba
+
+#ifndef BOOST_SYNC_IS_LOCKABLE_HPP
+#define BOOST_SYNC_IS_LOCKABLE_HPP
+
+#include <boost/config.hpp>
+#include <boost/sync/lockable_traits/detail/has_members.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+
+namespace boost
+{
+
+ template<typename T>
+ struct is_basic_lockable : integral_constant<bool,
+ sync::detail::has_member_lock<T>::value &&
+ sync::detail::has_member_unlock<T>::value
+ >
+ {
+ };
+
+ template<typename T>
+ struct is_try_lockable : integral_constant<bool,
+ is_basic_lockable<T>::value &&
+ sync::detail::has_member_try_lock<T>::value
+ >
+
+ {
+ };
+
+ template<typename T>
+ struct is_timed_lockable: integral_constant<bool,
+ is_try_lockable<T>::value &&
+ sync::detail::has_member_try_lock_until<T>::value &&
+ sync::detail::has_member_try_lock_for<T>::value
+ >
+
+ {
+ };
+
+}
+
+
+#endif
Modified: sandbox/sync/boost/sync/lockable_traits/is_lockable_type.hpp
==============================================================================
--- sandbox/sync/boost/sync/lockable_traits/is_lockable_type.hpp (original)
+++ sandbox/sync/boost/sync/lockable_traits/is_lockable_type.hpp 2010-09-23 08:13:31 EDT (Thu, 23 Sep 2010)
@@ -19,9 +19,9 @@
struct is_mutex_type
{
BOOST_STATIC_CONSTANT(bool, value =
- detail::has_member_lock<T>::value &&
- detail::has_member_unlock<T>::value &&
- detail::has_member_try_lock<T>::value);
+ boost::sync::detail::has_member_lock<T>::value &&
+ boost::sync::detail::has_member_unlock<T>::value &&
+ boost::sync::detail::has_member_try_lock<T>::value);
};
#else
Modified: sandbox/sync/boost/sync/null/null_mutex.hpp
==============================================================================
--- sandbox/sync/boost/sync/null/null_mutex.hpp (original)
+++ sandbox/sync/boost/sync/null/null_mutex.hpp 2010-09-23 08:13:31 EDT (Thu, 23 Sep 2010)
@@ -14,6 +14,7 @@
#include <boost/sync/lockable_traits.hpp>
//~ #include <boost/chrono/chrono.hpp>
+#include <boost/sync/lockable_traits/detail/has_members.hpp>
//!\file
//!Describes null_mutex classes
@@ -228,6 +229,14 @@
};
+// this is needed because we can not detect if a class has a template function.
+namespace detail {
+ template<>
+ struct has_member_try_lock_until<null_mutex> : boost::true_type {};
+ template<>
+ struct has_member_try_lock_for<null_mutex> : boost::true_type {};
+}
+
}
}
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