Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65388 - in sandbox/lockable_traits/boost/sync: . null
From: vicente.botet_at_[hidden]
Date: 2010-09-11 18:59:58


Author: viboes
Date: 2010-09-11 18:59:55 EDT (Sat, 11 Sep 2010)
New Revision: 65388
URL: http://svn.boost.org/trac/boost/changeset/65388

Log:
Added first version
Added:
   sandbox/lockable_traits/boost/sync/
   sandbox/lockable_traits/boost/sync/lock_options.hpp (contents, props changed)
   sandbox/lockable_traits/boost/sync/lockable_concepts.hpp (contents, props changed)
   sandbox/lockable_traits/boost/sync/lockable_generator.hpp (contents, props changed)
   sandbox/lockable_traits/boost/sync/lockable_traits.hpp (contents, props changed)
   sandbox/lockable_traits/boost/sync/null/
   sandbox/lockable_traits/boost/sync/null/null_condition.hpp (contents, props changed)
   sandbox/lockable_traits/boost/sync/null/null_mutex.hpp (contents, props changed)

Added: sandbox/lockable_traits/boost/sync/lock_options.hpp
==============================================================================
--- (empty file)
+++ sandbox/lockable_traits/boost/sync/lock_options.hpp 2010-09-11 18:59:55 EDT (Sat, 11 Sep 2010)
@@ -0,0 +1,45 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright 2007 Anthony Williams
+// (C) Copyright Ion Gaztanaga 2005-2009.
+// (C) Copyright Vicente J. Botet Escriba 2010.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying fileLICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/sync for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_SYNC_LOCK_OPTIONS_HPP
+#define BOOST_SYNC_LOCK_OPTIONS_HPP
+
+
+//!\file
+//!Describes the lock options associated with lock constructors.
+
+namespace boost {
+
+//!Type to indicate to a mutex lock constructor that must not lock the mutex.
+struct defer_lock_t{};
+//!Type to indicate to a mutex lock constructor that must try to lock the mutex.
+struct try_to_lock_t {};
+//!Type to indicate to a mutex lock constructor that the mutex is already locked.
+struct adopt_lock_t{};
+
+//!An object indicating that the locking
+//!must be deferred.
+static const defer_lock_t defer_lock = {};
+
+//!An object indicating that a try_lock()
+//!operation must be executed.
+static const try_to_lock_t try_to_lock = {};
+
+//!An object indicating that the ownership of lockable
+//!object must be accepted by the new owner.
+static const adopt_lock_t adopt_lock = {};
+
+} // namespace boost{
+
+
+#endif // BOOST_SYNC_LOCK_OPTIONS_HPP

Added: sandbox/lockable_traits/boost/sync/lockable_concepts.hpp
==============================================================================
--- (empty file)
+++ sandbox/lockable_traits/boost/sync/lockable_concepts.hpp 2010-09-11 18:59:55 EDT (Sat, 11 Sep 2010)
@@ -0,0 +1,180 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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)
+//
+// See http://www.boost.org/libs/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_SYNCHRO_LOCKABLE_CONCEPTS_HPP
+#define BOOST_SYNCHRO_LOCKABLE_CONCEPTS_HPP
+
+#include <boost/sync/lockable_traits.hpp>
+#include <boost/date_time/posix_time/ptime.hpp>
+//~ #include <boost/chrono/duration.hpp>
+//~ #include <boost/chrono/time_point.hpp>
+
+#include <boost/concept_check.hpp>
+namespace boost { namespace sync {
+
+/**
+ * LockableConcept object supports the basic features
+ * required to delimit a critical region
+ * Supports the basic lock, unlock and try_lock functions and
+ * defines the lock traits
+ */
+
+//[LockableConcept
+template <typename Lockable>
+struct BasicLockableConcept {
+ typedef typename category<Lockable>::type category;
+ typedef typename kind<Lockable>::type kind;
+ typedef typename reentrancy<Lockable>::type reentrancy;
+ typedef typename scope<Lockable>::type scope;
+ typedef typename lifetime<Lockable>::type lifetime;
+ typedef typename naming<Lockable>::type naming;
+
+ BOOST_CONCEPT_USAGE(BasicLockableConcept) {
+ l.lock();
+ l.unlock();
+ }
+ Lockable& l;
+};
+//]
+/**
+ * LockableConcept object supports the basic features
+ * required to delimit a critical region
+ * Supports the basic lock, unlock and try_lock functions and
+ * defines the lock traits
+ */
+
+//[LockableConcept
+template <typename Lockable>
+struct TryLockableConcept {
+ BOOST_CONCEPT_ASSERT((BasicLockableConcept<Lockable>));
+
+ BOOST_CONCEPT_USAGE(TryLockableConcept) {
+ l.lock();
+ l.unlock();
+ l.try_lock();
+ }
+ Lockable& l;
+};
+//]
+/**
+ * TimedLockableConcept object extends LockableConcept
+ * with timed lock functions: try_lock_until and try_lock_for and the exception based lock_until and lock_for
+ */
+
+//[TimedLockableConcept
+template <typename Lockable>
+struct TimedLockableConcept {
+ BOOST_CONCEPT_ASSERT((TryLockableConcept<Lockable>));
+
+ BOOST_CONCEPT_USAGE(TimedLockableConcept) {
+ //~ l.lock_until(t);
+ //~ l.lock_for(d);
+ l.try_lock_until(t);
+ l.try_lock_for(d);
+ }
+ Lockable& l;
+ //~ boost::chrono::system_clock::time_point t;
+ //~ boost::chrono::system_clock::duration d;
+ boost::posix_time::ptime t;
+ boost::posix_time::time_duration d;
+};
+//]
+//[ConditionLockableConcept
+template <typename Lockable>
+struct ConditionLockableConcept {
+ static bool pred();
+ BOOST_CONCEPT_ASSERT((TimedLockableConcept<Lockable>));
+ typedef typename Lockable::condition Condition;
+
+ BOOST_CONCEPT_USAGE(ConditionLockableConcept) {
+ l.lock_when(c, pred);
+ l.lock_when_until(c, pred, t);
+ l.lock_when_for(c, pred, d);
+ l.relock_on(t);
+ l.relock_on_until(c, t);
+ l.relock_on_for(c, d);
+ l.relock_when(c, pred);
+ l.relock_when_until(c, pred, t);
+ l.relock_when_for(c, pred, d);
+ c.notify_one();
+ c.notify_all();
+ }
+ Lockable& l;
+ Condition c;
+ //~ boost::chrono::system_clock::time_point t;
+ //~ boost::chrono::system_clock::duration d;
+ boost::posix_time::ptime t;
+ boost::posix_time::time_duration d;
+};
+
+
+//]
+/**
+ * ShareLockableConcept object extends TimedLockableConcept
+ * with the lock_shared, lock_shared_until, lock_shared_for, try_lock_shared_until, try_lock_shared
+ * and unlock_shared functions
+ */
+//[ShareLockableConcept
+template <typename Lockable>
+struct ShareLockableConcept {
+ BOOST_CONCEPT_ASSERT((TimedLockableConcept<Lockable>));
+
+ BOOST_CONCEPT_USAGE(ShareLockableConcept) {
+ l.lock_shared();
+ //~ l.lock_shared_until(t);
+ //~ l.lock_shared_for(d);
+ l.try_lock_shared();
+ l.try_lock_shared_until(t);
+ l.try_lock_shared_for(d);
+ l.unlock_shared();
+ }
+ Lockable& l;
+ //~ boost::chrono::system_clock::time_point t;
+ //~ boost::chrono::system_clock::duration d;
+ boost::posix_time::ptime t;
+ boost::posix_time::time_duration d;
+};
+//]
+
+
+/**
+ * UpgradeLockableConcept object extends SharableLockableConcept
+ * with the lock_upgrade, lock_upgrade_until, unlock_upgrade_and_lock,
+ * unlock_and_lock_shared and unlock_upgrade_and_lock_shared functions
+ */
+
+//[UpgradeLockableConcept
+template <typename Lockable>
+struct UpgradeLockableConcept {
+ BOOST_CONCEPT_ASSERT((ShareLockableConcept<Lockable>));
+
+ BOOST_CONCEPT_USAGE(UpgradeLockableConcept) {
+ l.lock_upgrade();
+ //~ l.lock_upgrade_until(t);
+ //~ l.lock_upgrade_for(d);
+ l.try_lock_upgrade();
+ l.try_lock_upgrade_until(t);
+ l.try_lock_upgrade_for(d);
+ l.unlock_upgrade_and_lock();
+ l.unlock_and_lock_upgrade();
+ l.unlock_and_lock_shared();
+ l.unlock_upgrade_and_lock_shared();
+ }
+ Lockable& l;
+ //~ boost::chrono::system_clock::time_point t;
+ //~ boost::chrono::system_clock::duration d;
+ boost::posix_time::ptime t;
+ boost::posix_time::time_duration d;
+};
+//]
+
+}
+}
+#endif

Added: sandbox/lockable_traits/boost/sync/lockable_generator.hpp
==============================================================================
--- (empty file)
+++ sandbox/lockable_traits/boost/sync/lockable_generator.hpp 2010-09-11 18:59:55 EDT (Sat, 11 Sep 2010)
@@ -0,0 +1,223 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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)
+//
+// See http://www.boost.org/libs/synch for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_SYNCH_LOCK_GENERATOR__HPP
+#define BOOST_SYNCH_LOCK_GENERATOR__HPP
+
+#include <boost/sync/lockable_traits.hpp>
+#include <boost/interprocess/sync/null_mutex.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/interprocess/sync/interprocess_mutex.hpp>
+#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
+#include <boost/interprocess/sync/interprocess_upgradable_mutex.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/type_traits.hpp>
+
+namespace boost {
+namespace synch {
+
+template<
+ typename Scope,
+ typename Category,
+ typename Reentrancy,
+ typename Kind,
+ typename Lifetime,
+ typename Naming
+>
+struct find_best_lock;
+
+template<
+typename Lockable,
+typename Category,
+typename Scope,
+typename Reentrancy,
+typename Kind,
+typename Lifetime,
+typename Naming
+>
+struct lock_matches_features : mpl::and_<
+mpl::and_<
+ boost::is_base_and_derived<Category, typename category_tag<Lockable>::type>,
+ boost::is_base_and_derived<Scope, typename scope_tag<Lockable>::type>,
+ boost::is_base_and_derived<Reentrancy, typename reentrancy_tag<Lockable>::type> >,
+
+ boost::is_base_and_derived<Kind, typename kind<Lockable>::type>,
+ boost::is_base_and_derived<Lifetime, typename lifetime_tag<Lockable>::type>,
+ boost::is_base_and_derived<Naming, typename naming_tag<Lockable>::type>
+> {};
+
+template<
+ typename Lockables,
+ , typename constraint
+struct fill_matches_features : mpl::copy_if<Lockables, constraint>
+
+//template<
+// typename Lockables,
+// typename Lockables,
+//struct filter : mpl::and_<
+
+template<typename Scope>
+struct default_lifetime;
+
+template<>
+struct default_lifetime<multi_threaded_tag> {
+ typedef process_lifetime_tag type;
+};
+
+template<>
+struct default_lifetime<multi_process_tag> {
+ typedef kernel_lifetime_tag type;
+};
+
+
+template<
+ typename Scope=multi_threaded_tag,
+ typename Category=exclusive_lock_tag,
+ typename Reentrancy=non_recursive_tag,
+ typename Kind=timed_lockable_tag,
+ typename Lifetime=typename default_lifetime<Scope>,
+ typename Naming=anonymous_tag
+>
+struct find_best_lock;
+
+template<
+ typename Category,
+ typename Reentrancy,
+ typename Kind,
+ typename Lifetime,
+ typename Naming
+>
+struct find_best_lock<
+ mono_threaded_tag,
+ Category,
+ Reentrancy,
+ TimedInterface,
+ Lifetime,
+ Naming
+> {
+ typedef boost::interprocess::sync::null_mutex type;
+};
+
+template<>
+struct find_best_lock<
+ multi_threaded_tag,
+ exclusive_lock_tag,
+ non_recursive_tag,
+ timed_lockable_tag,
+ process_lifetime_tag,
+ anonymous_tag
+> {
+ typedef boost::mutex type;
+};
+
+template<>
+struct find_best_lock<
+ multi_threaded_tag,
+ exclusive_lock_tag,
+ recursive_tag,
+ timed_lockable_tag,
+ process_lifetime_tag,
+ anonymous_tag
+> {
+ typedef boost::recursive_mutex type;
+};
+
+template<>
+struct find_best_lock<
+ multi_threaded_tag,
+ exclusive_lock_tag,
+ non_recursive_tag,
+ timed_lockable_tag,
+ process_lifetime_tag,
+ anonymous_tag
+> {
+ typedef boost::timed_mutex type;
+};
+
+template<>
+struct find_best_lock<
+ multi_threaded_tag,
+ exclusive_lock_tag,
+ recursive_tag,
+ timed_lockable_tag,
+ process_lifetime_tag,
+ anonymous_tag
+> {
+ typedef boost::recursive_timed_mutex type;
+};
+
+template <
+ typename Category,
+ typename Kind
+>
+struct find_best_lock<
+ multi_threaded_tag,
+ Category,
+ non_recursive_tag,
+ Kind,
+ process_lifetime_tag,
+ anonymous_tag
+> {
+ typedef boost::shared_mutex type;
+};
+
+//////////////////////////
+
+template <
+ typename Kind
+>
+struct find_best_lock<
+ multi_process_tag,
+ exclusive_lock_tag,
+ non_recursive_tag,
+ Kind,
+ kernel_lifetime_tag,
+ anonymous_tag
+> {
+ typedef boost::interprocess::sync::interprocess_mutex type;
+};
+
+template <
+ typename Kind
+>
+struct find_best_lock<
+ multi_process_tag,
+ exclusive_lock_tag,
+ recursive_tag,
+ Kind,
+ kernel_lifetime_tag,
+ anonymous_tag
+> {
+ typedef boost::interprocess::sync::interprocess_recursive_mutex type;
+};
+
+
+template <
+ typename Category,
+ typename Kind
+>
+struct find_best_lock<
+ multi_process_tag,
+ Category,
+ non_recursive_tag,
+ Kind,
+ kernel_lifetime_tag,
+ anonymous_tag
+> {
+ typedef boost::interprocess::sync::interprocess_upgradable_mutex type;
+};
+
+
+}
+}
+
+#endif

Added: sandbox/lockable_traits/boost/sync/lockable_traits.hpp
==============================================================================
--- (empty file)
+++ sandbox/lockable_traits/boost/sync/lockable_traits.hpp 2010-09-11 18:59:55 EDT (Sat, 11 Sep 2010)
@@ -0,0 +1,382 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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)
+//
+// See http://www.boost.org/libs/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_SYNCH_LOCKABLE_TRAITS__HPP
+#define BOOST_SYNCH_LOCKABLE_TRAITS__HPP
+
+#include <boost/type_traits.hpp>
+#include <boost/mpl/or.hpp>
+
+namespace boost { namespace sync {
+
+namespace sync_detail {
+template <typename B, typename D>
+struct is_same_or_is_base_and_derived
+ : mpl::or_<is_same<B,D>, is_base_and_derived<B,D> >
+{};
+}
+
+/**
+ * a scope_tag forms a hierarchy
+ * mono_threaded_tag <- multi_threaded_tag <- multi_process_tag
+ */
+
+//[scope_tag_hierarchy
+struct mono_threaded_tag {};
+struct multi_threaded_tag : mono_threaded_tag {};
+struct multi_process_tag : multi_threaded_tag {};
+//]
+
+/**
+ * A lockable implementer must either
+ * inherit from the helper lockable_base or
+ * have a nested type scope or
+ * specialize the scope_tag template class
+ */
+
+//[scope_tag
+template <typename Lockable>
+struct scope {
+ typedef typename Lockable::scope type;
+};
+//]
+
+/**
+ * Inherits: If Lockable has a scope_tag that inherits from
+ * then mono_threaded_tag then inherits from true_type,
+ * otherwise inherits from false_type.
+ */
+//[is_mono_threaded
+template <typename Lockable>
+struct is_mono_threaded
+ : sync_detail::is_same_or_is_base_and_derived<
+ mono_threaded_tag,
+ typename scope<Lockable>::type
+ >
+{};
+//]
+
+/**
+ * Inherits: If Lockable has a scope_tag that inherits from
+ * then multi_threaded_tag then inherits from true_type,
+ * otherwise inherits from false_type.
+ */
+//[is_multi_threaded
+template <typename Lockable>
+struct is_multi_threaded
+ : sync_detail::is_same_or_is_base_and_derived<
+ multi_threaded_tag,
+ typename scope<Lockable>::type
+ >
+{};
+//]
+
+/**
+ * Inherits: If Lockable has a scope_tag that inherits from
+ * then multi_process_tag then inherits from true_type,
+ * otherwise inherits from false_type.
+ */
+
+template <typename Lockable>
+struct is_multi_process
+ : sync_detail::is_same_or_is_base_and_derived<
+ multi_process_tag,
+ typename scope<Lockable>::type
+ >
+{};
+
+/**
+ * a lifetime_tag forms a hierarchy
+ * process_lifetime_tag <- kernel_lifetime_tag <- filesystem_lifetime_tag
+ */
+//[lifetime_tag_hierarchy
+struct process_lifetime_tag {};
+struct kernel_lifetime_tag : process_lifetime_tag {};
+struct filesystem_lifetime_tag : kernel_lifetime_tag {};
+//]
+/**
+ * A lockable implementer must either
+ * inherit from the helper lockable_base or
+ * have a nested type lifetime or
+ * specialize the lifetime_tag template class
+ */
+
+template <typename Lockable>
+struct lifetime {
+ typedef typename Lockable::lifetime type;
+};
+
+/**
+ * a naming_tags forms a hierarchy
+ * anonymous_tag <- named_tag
+ */
+
+struct anonymous_tag {};
+struct named_tag : anonymous_tag {};
+
+/**
+ * A lockable implementer must either
+ * inherit from the helper lockable_base or
+ * have a nested type naming or
+ * specialize the naming_tag template class
+ */
+
+template <typename Lockable>
+struct naming {
+ typedef typename Lockable::naming type;
+};
+
+/**
+ * a category_tag forms a hierarchy
+ * exclusive_lock_tag <- sharable_lock_tag <- upgradable_lock_tag
+ */
+//[category_tag_hierarchy
+struct exclusive_lock_tag {};
+struct sharable_lock_tag : exclusive_lock_tag {};
+struct upgradable_lock_tag : sharable_lock_tag {};
+//]
+/**
+ * A lockable implementer must either
+ * inherit from the helper lockable_base or
+ * have a nested type category or
+ * specialize the category_tag template class
+ */
+
+template <typename Lockable>
+struct category {
+ typedef typename Lockable::category type;
+};
+
+/**
+ * Inherits: If Lockable has a category_tag that inherits from
+ * then exclusive_lock_tag then inherits from true_type,
+ * otherwise inherits from false_type.
+ */
+
+template <typename Lockable>
+struct is_exclusive_lock
+ : sync_detail::is_same_or_is_base_and_derived<
+ exclusive_lock_tag,
+ typename category<Lockable>::type
+ >
+{};
+
+/**
+ * Inherits: If Lockable has a category_tag that inherits from
+ * then sharable_lock_tag then inherits from true_type,
+ * otherwise inherits from false_type.
+ */
+
+template <typename Lockable>
+struct is_sharable_lock
+ : sync_detail::is_same_or_is_base_and_derived<
+ sharable_lock_tag,
+ typename category<Lockable>::type
+ >
+{};
+
+/**
+ * Inherits: If Lockable has a category_tag that inherits from
+ * then upgradable_lock_tag then inherits from true_type,
+ * otherwise inherits from false_type.
+ */
+
+template <typename Lockable>
+struct is_upgradable_lock
+ : sync_detail::is_same_or_is_base_and_derived<
+ upgradable_lock_tag,
+ typename category<Lockable>::type
+ >
+{};
+
+/**
+ * a reentrancy_tag formas a hierarchy
+ * non_recursive_tag <- recursive_tag
+ */
+//[reentrancy_tag_hierarchy
+struct non_recursive_tag {};
+struct recursive_tag : non_recursive_tag {};
+//]
+
+/**
+ * A lockable implementer must either
+ * inherit from the helper lockable_base or
+ * have a nested type reentrancy or
+ * specialize the reentrancy_tag template class
+ */
+
+template <typename Lockable>
+struct reentrancy {
+ typedef typename Lockable::reentrancy type;
+};
+
+/**
+ * Inherits: If Lockable has a reentrancy_tag that inherits from
+ * then recursive_tag then inherits from true_type,
+ * otherwise inherits from false_type.
+ */
+template <typename Lockable>
+struct is_recursive_lock
+ : sync_detail::is_same_or_is_base_and_derived<
+ recursive_tag,
+ typename reentrancy<Lockable>::type
+ >
+{};
+
+/**
+ * a kind forms a hierarchy
+ * basic_lockable_tag <- try_lockable_tag <- timed_lockable_tag
+ */
+
+//[kind_hierarchy
+struct basic_lockable_tag {};
+struct try_lockable_tag : basic_lockable_tag {};
+struct timed_lockable_tag : try_lockable_tag {};
+//]
+/**
+ * A lockable implementer must either
+ * inherit from the helper lockable_base or
+ * have a nested type kind or
+ * specialize the kind template class
+ */
+
+template <typename Lockable>
+struct kind {
+ typedef typename Lockable::kind type;
+};
+
+/**
+ * Inherits: If Lockable has a kind that inherits from
+ * then lockable_tag then inherits from true_type,
+ * otherwise inherits from false_type.
+ */
+
+template <typename Lockable>
+struct is_basic_lockable
+ : sync_detail::is_same_or_is_base_and_derived<
+ basic_lockable_tag,
+ typename kind<Lockable>::type
+ >
+{};
+
+/**
+ * Inherits: If Lockable has a kind that inherits from
+ * then try_lockable_tag then inherits from true_type,
+ * otherwise inherits from false_type.
+ */
+
+template <typename Lockable>
+struct is_try_lockable
+ : sync_detail::is_same_or_is_base_and_derived<
+ try_lockable_tag,
+ typename kind<Lockable>::type
+ >
+{};
+
+/**
+ * Inherits: If Lockable has a kind that inherits from
+ * then timed_lockable_tag then inherits from true_type,
+ * otherwise inherits from false_type.
+ */
+
+template <typename Lockable>
+struct is_timed_lockable
+ : sync_detail::is_same_or_is_base_and_derived<
+ timed_lockable_tag,
+ typename kind<Lockable>::type
+ >
+{};
+
+template <typename Lockable>
+struct best_condition {
+ typedef typename Lockable::best_condition_type type;
+};
+
+template <typename Lockable>
+struct best_condition_any {
+ typedef typename Lockable::best_condition_any_type type;
+};
+
+template<typename Scope>
+struct default_lifetime;
+
+template<>
+struct default_lifetime<multi_threaded_tag> {
+ typedef process_lifetime_tag type;
+};
+
+template<>
+struct default_lifetime<multi_process_tag> {
+ typedef kernel_lifetime_tag type;
+};
+
+//[lockable_base_defaults
+template<
+ typename Scope=multi_threaded_tag,
+ typename Category=exclusive_lock_tag,
+ typename Reentrancy=non_recursive_tag,
+ typename Kind=try_lockable_tag,
+ //~ typename Lifetime=typename default_lifetime<Scope>::type,
+ typename Lifetime=process_lifetime_tag,
+ typename Naming=anonymous_tag,
+ typename Base=void
+> struct lockable_base;
+//]
+/**
+ * lockable_base is helper class that servs as a base class of lockables.
+ */
+
+//[lockable_base
+template<
+ typename Scope,
+ typename Category,
+ typename Reentrancy,
+ typename Kind,
+ typename Lifetime,
+ typename Naming,
+ typename Base
+>
+struct lockable_base : Base {
+ // TODO add constraints on typenames
+ typedef Scope scope;
+ typedef Category category;
+ typedef Reentrancy reentrancy;
+ typedef Kind kind;
+ typedef Lifetime lifetime;
+ typedef Naming naming;
+};
+//]
+
+//[lockable_base_void
+template<
+ typename Scope,
+ typename Category,
+ typename Reentrancy,
+ typename Kind,
+ typename Lifetime,
+ typename Naming
+>
+struct lockable_base<Scope, Category, Reentrancy, Kind, Lifetime, Naming, void> {
+ typedef Scope scope;
+ typedef Category category;
+ typedef Reentrancy reentrancy;
+ typedef Kind kind;
+ typedef Lifetime lifetime;
+ typedef Naming naming;
+};
+//]
+
+
+}
+}
+
+
+#endif
+

Added: sandbox/lockable_traits/boost/sync/null/null_condition.hpp
==============================================================================
--- (empty file)
+++ sandbox/lockable_traits/boost/sync/null/null_condition.hpp 2010-09-11 18:59:55 EDT (Sat, 11 Sep 2010)
@@ -0,0 +1,84 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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)
+//
+// See http://www.boost.org/libs/sync for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_SYNC_NULL_CONDITION__HPP
+#define BOOST_SYNC_NULL_CONDITION__HPP
+
+//!\file
+//!Describes null_mutex class
+#include <boost/sync/null/null_mutex.hpp>
+
+namespace boost {
+
+namespace posix_time
+{ class ptime; }
+
+namespace sync {
+
+class null_condition
+{
+ //Non-copyable
+ //~ null_condition(const null_condition &); // = delete
+ //~ null_condition & opertator=(const null_condition &); // = delete
+public:
+
+ //!Constructs a null_condition. On error throws interprocess_exception.
+ null_condition(){}
+
+ //!Destroys *this
+ //!liberating system resources.
+ ~null_condition(){}
+
+ //!If there is a thread waiting on *this, change that
+ //!thread's state to ready. Otherwise there is no effect.
+ void notify_one(){}
+
+ //!Change the state of all threads waiting on *this to ready.
+ //!If there are no waiting threads, notify_all() has no effect.
+ void notify_all(){}
+
+ //!Releases the lock on the interprocess_mutex object associated with lock, blocks
+ //!the current thread of execution until readied by a call to
+ //!this->notify_one() or this->notify_all(), and then reacquires the lock.
+ template <typename L>
+ void wait(L& lock) {}
+
+ //!The same as:
+ //!while (!pred()) wait(lock)
+ template <typename L, typename Pr>
+ void wait(L& lock, Pr pred) {}
+
+ //!Releases the lock on the interprocess_mutex object associated with lock, blocks
+ //!the current thread of execution until readied by a call to
+ //!this->notify_one() or this->notify_all(), or until time abs_time is reached,
+ //!and then reacquires the lock.
+ //!Returns: false if time abs_time is reached, otherwise true.
+
+ template <typename L>
+ bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time)
+ { return true; }
+
+ //!The same as: while (!pred()) {
+ //! if (!timed_wait(lock, abs_time)) return pred();
+ //! } return true;
+ template <typename L, typename Pr>
+ bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr pred)
+ { return true; }
+
+};
+template <>
+struct best_condition<null_mutex> {
+ typedef null_condition type;
+};
+
+}
+}
+
+#endif // __BOOST_SYNC_NULL_CONDITION__HPP

Added: sandbox/lockable_traits/boost/sync/null/null_mutex.hpp
==============================================================================
--- (empty file)
+++ sandbox/lockable_traits/boost/sync/null/null_mutex.hpp 2010-09-11 18:59:55 EDT (Sat, 11 Sep 2010)
@@ -0,0 +1,236 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2005-2009.
+// (C) Copyright Vicente J. Botet Escriba 2008-2009.
+// 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)
+//
+// See http://www.boost.org/libs/sync for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_SYNC_NULL_CONDITION_HPP
+#define BOOST_SYNC_NULL_CONDITION_HPP
+
+
+#include <boost/sync/lockable_traits.hpp>
+//~ #include <boost/chrono/chrono.hpp>
+
+//!\file
+//!Describes null_mutex classes
+
+namespace boost {
+
+namespace posix_time
+{ class ptime; }
+
+namespace sync {
+class null_condition;
+//!Implements a mutex that simulates a mutex without doing any operation and
+//!simulates a successful operation.
+class null_mutex
+: public lockable_base<
+ mono_threaded_tag,
+ upgradable_lock_tag,
+ recursive_tag,
+ timed_lockable_tag, void
+>
+{
+ //~ null_mutex(const null_mutex &); // = delete
+ //~ null_mutex & opertator=(const null_mutex &); // = delete
+public:
+ typedef null_condition best_condition_type;
+ typedef null_condition best_condition_any_type;
+
+
+ //!Constructor.
+ //!Empty.
+ null_mutex(){}
+
+ //!Destructor.
+ //!Empty.
+ ~null_mutex(){}
+
+ //!Simulates a mutex lock() operation. Empty function.
+ void lock(){}
+
+ //!Simulates a mutex try_lock() operation.
+ //!Equivalent to "return true;"
+ bool try_lock()
+ { return true; }
+
+ //!Simulates a mutex timed_lock() operation.
+ //!Equivalent to "return true;"
+ bool try_lock_until(const boost::posix_time::ptime &)
+ { return true; }
+
+ //!Simulates a mutex try_lock_for() operation.
+ //!Equivalent to "return true;"
+ template<typename TimeDuration>
+ bool try_lock_for(TimeDuration const &)
+ {return true;}
+
+ //~ template<typename Clock, typename Duration>
+ //~ bool try_lock_until(chrono::time_point<Clock, Duration> const & abs_time)
+ //~ {return true;}
+
+ //~ template<typename Rep, typename Period>
+ //~ bool try_lock_for(chrono::duration<Rep, Period> const & rel_time)
+ //~ {return true;}
+
+ //!Simulates a mutex timed_lock() operation.
+ //!Equivalent to "return true;"
+ bool lock_until(const boost::posix_time::ptime &)
+ { return true; }
+
+ //!Simulates a mutex lock_for() operation.
+ //!Equivalent to "return true;"
+ template<typename TimeDuration>
+ bool lock_for(TimeDuration const &)
+ {return true;}
+
+ //~ template<typename Clock, typename Duration>
+ //~ void lock_until(chrono::time_point<Clock, Duration> const & abs_time)
+ //~ {}
+
+ //~ template<typename Rep, typename Period>
+ //~ void lock_for(chrono::duration<Rep, Period> const & rel_time)
+ //~ {}
+
+ //!Simulates a mutex unlock() operation.
+ //!Empty function.
+ void unlock(){}
+
+ //!Simulates a mutex lock_share() operation.
+ //!Empty function.
+ void lock_shared(){}
+
+ //!Simulates a mutex try_lock_share() operation.
+ //!Equivalent to "return true;"
+ bool try_lock_shared()
+ { return true; }
+
+ //!Simulates a mutex try_lock_shared_until() operation.
+ //!Equivalent to "return true;"
+ bool try_lock_shared_until(const boost::posix_time::ptime &)
+ { return true; }
+
+ //!Simulates a mutex try_lock_shared_for() operation.
+ //!Equivalent to "return true;"
+ template<typename TimeDuration>
+ bool try_lock_shared_for(const TimeDuration &)
+ { return true; }
+
+ //~ template<typename Clock, typename Duration>
+ //~ bool try_lock_shared_until(chrono::time_point<Clock, Duration> const & relative_time)
+ //~ {return true;}
+
+ //~ template<typename Rep, typename Period>
+ //~ bool try_lock_shared_for(chrono::duration<Rep, Period> const & relative_time)
+ //~ {return true;}
+
+ //!Simulates a mutex lock_shared_until() operation.
+ //!Equivalent to "return true;"
+ bool lock_shared_until(const boost::posix_time::ptime &)
+ { return true; }
+
+ //!Simulates a mutex lock_shared_for() operation.
+ //!Equivalent to "return true;"
+ template<typename TimeDuration>
+ bool lock_shared_for(const TimeDuration &)
+ { return true; }
+
+ //~ template<typename Clock, typename Duration>
+ //~ void lock_shared_until(chrono::time_point<Clock, Duration> const & relative_time)
+ //~ {}
+ //~ template<typename Rep, typename Period>
+ //~ void lock_shared_for(chrono::duration<Rep, Period> const & relative_time)
+ //~ {}
+
+ //!Simulates a mutex unlock_share() operation.
+ //!Empty function.
+ void unlock_shared(){}
+
+ //!Simulates a mutex lock_upgrade() operation.
+ //!Empty function.
+ void lock_upgrade(){}
+
+ //!Simulates a mutex try_lock_upgrade() operation.
+ //!Equivalent to "return true;"
+ bool try_lock_upgrade()
+ { return true; }
+
+ //!Simulates a mutex try_lock_upgrade_until() operation.
+ //!Equivalent to "return true;"
+ bool try_lock_upgrade_until(boost::posix_time::ptime const &)
+ { return true; }
+
+ template<typename TimeDuration>
+ bool try_lock_upgrade_for(TimeDuration const &)
+ {return true;}
+
+ //~ template<typename Clock, typename Duration>
+ //~ bool try_lock_upgrade_until(chrono::time_point<Clock, Duration> const & relative_time)
+ //~ {return true;}
+
+ //~ template<typename Rep, typename Period>
+ //~ bool try_lock_upgrade_for(chrono::duration<Rep, Period> const & relative_time)
+ //~ {return true;}
+
+ //!Simulates a mutex unlock_upgrade() operation.
+ //!Empty function.
+ void unlock_upgrade(){}
+
+ //!Simulates unlock_and_lock_upgrade().
+ //!Empty function.
+ void unlock_and_lock_upgrade(){}
+
+ //!Simulates unlock_and_lock_share().
+ //!Empty function.
+ void unlock_and_lock_shared(){}
+
+ //!Simulates unlock_upgrade_and_lock_share().
+ //!Empty function.
+ void unlock_upgrade_and_lock_shared(){}
+
+ //Promotions
+
+ //!Simulates unlock_upgrade_and_lock().
+ //!Empty function.
+ void unlock_upgrade_and_lock(){}
+
+ //!Simulates try_unlock_upgrade_and_lock().
+ //!Equivalent to "return true;"
+ bool try_unlock_upgrade_and_lock()
+ { return true; }
+
+ //!Simulates unlock_upgrade_and_lock_until().
+ //!Equivalent to "return true;"
+ bool unlock_upgrade_and_lock_until(const boost::posix_time::ptime &)
+ { return true; }
+
+ //~ template<typename Clock, typename Duration>
+ //~ bool unlock_upgrade_and_lock_until(chrono::time_point<Clock, Duration> const & relative_time)
+ //~ {return true;}
+
+ //~ template<typename Rep, typename Period>
+ //~ bool unlock_upgrade_and_lock_for(chrono::duration<Rep, Period> const & relative_time)
+ //~ {return true;}
+
+ //!Simulates try_unlock_share_and_lock().
+ //!Equivalent to "return true;"
+ bool try_unlock_share_and_lock()
+ { return true; }
+
+ //!Simulates try_unlock_share_and_lock_upgrade().
+ //!Equivalent to "return true;"
+ bool try_unlock_share_and_lock_upgrade()
+ { return true; }
+};
+
+
+}
+}
+
+#endif //BOOST_SYNC_NULL_MUTEX_HPP


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