Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51153 - sandbox/synchro/boost/synchro
From: vicente.botet_at_[hidden]
Date: 2009-02-09 17:25:27


Author: viboes
Date: 2009-02-09 17:25:26 EST (Mon, 09 Feb 2009)
New Revision: 51153
URL: http://svn.boost.org/trac/boost/changeset/51153

Log:
Boost.Synchro V0.0.0
Added:
   sandbox/synchro/boost/synchro/lock_generator.hpp (contents, props changed)
   sandbox/synchro/boost/synchro/lockable_concepts.hpp (contents, props changed)
   sandbox/synchro/boost/synchro/lockable_scope_traits.hpp (contents, props changed)
   sandbox/synchro/boost/synchro/lockable_traits.hpp (contents, props changed)
   sandbox/synchro/boost/synchro/locker_concepts.hpp (contents, props changed)
   sandbox/synchro/boost/synchro/make_lockable.hpp (contents, props changed)
   sandbox/synchro/boost/synchro/monitor.hpp (contents, props changed)
   sandbox/synchro/boost/synchro/null_condition.hpp (contents, props changed)
   sandbox/synchro/boost/synchro/null_mutex.hpp (contents, props changed)
   sandbox/synchro/boost/synchro/null_synchronization_family.hpp (contents, props changed)
   sandbox/synchro/boost/synchro/process_synchronization_family.hpp (contents, props changed)
   sandbox/synchro/boost/synchro/semaphore.hpp (contents, props changed)
   sandbox/synchro/boost/synchro/syntactic_lock_traits.hpp (contents, props changed)

Added: sandbox/synchro/boost/synchro/lock_generator.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/synchro/lock_generator.hpp 2009-02-09 17:25:26 EST (Mon, 09 Feb 2009)
@@ -0,0 +1,223 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008. 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_LOCK_GENERATOR__HPP
+#define BOOST_SYNCHRO_LOCK_GENERATOR__HPP
+
+#include "boost/synchro/lock_traits.hpp"
+#include "boost/synchro/null/mutex.hpp"
+#include "boost/synchro/thread/mutex.hpp"
+#include "boost/synchro/thread/recursive_mutex.hpp"
+#include "boost/synchro/thread/shared_mutex.hpp"
+#include "boost/synchro/process/mutex.hpp"
+#include "boost/synchro/process/recursive_mutex.hpp"
+#include "boost/synchro/process/upgradable_mutex.hpp"
+#include "boost/mpl/and.hpp"
+#include "boost/type_traits.hpp"
+
+namespace boost {
+namespace synchro {
+
+template<
+ typename Scope,
+ typename Category,
+ typename Reentrancy,
+ typename TimedInterface,
+ typename Lifetime,
+ typename Naming
+>
+struct find_best_lock;
+
+template<
+typename Lockable,
+typename Category,
+typename Scope,
+typename Reentrancy,
+typename TimedInterface,
+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<TimedInterface, typename timed_interface_tag<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 TimedInterface=has_timed_interface_tag,
+ typename Lifetime=typename default_lifetime<Scope>,
+ typename Naming=anonymous_tag
+>
+struct find_best_lock;
+
+template<
+ typename Category,
+ typename Reentrancy,
+ typename TimedInterface,
+ typename Lifetime,
+ typename Naming
+>
+struct find_best_lock<
+ mono_threaded_tag,
+ Category,
+ Reentrancy,
+ TimedInterface,
+ Lifetime,
+ Naming
+> {
+ typedef boost::synchro::null_mutex type;
+};
+
+template<>
+struct find_best_lock<
+ multi_threaded_tag,
+ exclusive_lock_tag,
+ non_recursive_tag,
+ hasnt_timed_interface_tag,
+ process_lifetime_tag,
+ anonymous_tag
+> {
+ typedef boost::mutex type;
+};
+
+template<>
+struct find_best_lock<
+ multi_threaded_tag,
+ exclusive_lock_tag,
+ recursive_tag,
+ hasnt_timed_interface_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,
+ has_timed_interface_tag,
+ process_lifetime_tag,
+ anonymous_tag
+> {
+ typedef boost::timed_mutex type;
+};
+
+template<>
+struct find_best_lock<
+ multi_threaded_tag,
+ exclusive_lock_tag,
+ recursive_tag,
+ has_timed_interface_tag,
+ process_lifetime_tag,
+ anonymous_tag
+> {
+ typedef boost::recursive_timed_mutex type;
+};
+
+template <
+ typename Category,
+ typename TimedInterface
+>
+struct find_best_lock<
+ multi_threaded_tag,
+ Category,
+ non_recursive_tag,
+ TimedInterface,
+ process_lifetime_tag,
+ anonymous_tag
+> {
+ typedef boost::shared_mutex type;
+};
+
+//////////////////////////
+
+template <
+ typename TimedInterface
+>
+struct find_best_lock<
+ multi_process_tag,
+ exclusive_lock_tag,
+ non_recursive_tag,
+ TimedInterface,
+ kernel_lifetime_tag,
+ anonymous_tag
+> {
+ typedef boost::synchro::interprocess_mutex type;
+};
+
+template <
+ typename TimedInterface
+>
+struct find_best_lock<
+ multi_process_tag,
+ exclusive_lock_tag,
+ recursive_tag,
+ TimedInterface,
+ kernel_lifetime_tag,
+ anonymous_tag
+> {
+ typedef boost::synchro::interprocess_recursive_mutex type;
+};
+
+
+template <
+ typename Category,
+ typename TimedInterface
+>
+struct find_best_lock<
+ multi_process_tag,
+ Category,
+ non_recursive_tag,
+ TimedInterface,
+ kernel_lifetime_tag,
+ anonymous_tag
+> {
+ typedef boost::synchro::interprocess_upgradable_mutex type;
+};
+
+
+}
+}
+
+#endif

Added: sandbox/synchro/boost/synchro/lockable_concepts.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/synchro/lockable_concepts.hpp 2009-02-09 17:25:26 EST (Mon, 09 Feb 2009)
@@ -0,0 +1,112 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008. 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/synchro/lockable_traits.hpp"
+#include <boost/date_time/posix_time/ptime.hpp>
+#include <boost/thread/thread_time.hpp>
+#include <boost/concept_check.hpp>
+namespace boost { namespace synchro {
+
+/**
+ * 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 LockableConcept {
+ typedef typename category_tag<Lockable>::type category;
+ typedef typename timed_interface_tag<Lockable>::type timed_interface;
+ typedef typename reentrancy_tag<Lockable>::type reentrancy;
+ typedef typename scope_tag<Lockable>::type scope;
+ typedef typename lifetime_tag<Lockable>::type lifetime;
+ typedef typename naming_tag<Lockable>::type naming;
+
+ BOOST_CONCEPT_USAGE(LockableConcept) {
+ l.lock();
+ l.unlock();
+ l.try_lock();
+ }
+ Lockable l;
+};
+//]
+/**
+ * TimedLockableConcept object extends ExclusiveLockConcept
+ * with the timed_lock function
+ */
+
+//[TimedLockableConcept
+template <typename Lockable>
+struct TimedLockableConcept {
+ BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
+
+ BOOST_CONCEPT_USAGE(TimedLockableConcept) {
+ l.timed_lock(t);
+// l.timed_lock(1);
+ }
+ Lockable l;
+ system_time t;
+};
+//]
+
+/**
+ * ShareLockableConcept object extends ExclusiveTimedLockConcept
+ * with the lock_shared, timed_lock_shared, 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.timed_lock_shared(t);
+ l.try_lock_shared();
+ l.unlock_shared();
+ }
+ Lockable l;
+ system_time t;
+};
+//]
+
+
+/**
+ * UpgradeLockableConcept object extends SharableLockableConcept
+ * with the lock_upgrade, timed_lock_upgrade, 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.timed_lock_upgrade(t);
+ l.unlock_upgrade_and_lock();
+ l.unlock_and_lock_upgrade();
+ l.unlock_and_lock_shared();
+ l.unlock_upgrade_and_lock_shared();
+ }
+ Lockable l;
+ system_time t;
+};
+//]
+
+}
+}
+#endif

Added: sandbox/synchro/boost/synchro/lockable_scope_traits.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/synchro/lockable_scope_traits.hpp 2009-02-09 17:25:26 EST (Mon, 09 Feb 2009)
@@ -0,0 +1,26 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008. 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_SCOPE_TRAITS__HPP
+#define BOOST_SYNCHRO_LOCKABLE_SCOPE_TRAITS__HPP
+
+namespace boost { namespace synchro {
+
+//[lockable_scope_traits
+template<typename Scope>
+struct scope_traits;
+template<typename Scope, typename Lockable>
+struct lockable_scope_traits;
+
+//]
+}
+}
+
+#endif

Added: sandbox/synchro/boost/synchro/lockable_traits.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/synchro/lockable_traits.hpp 2009-02-09 17:25:26 EST (Mon, 09 Feb 2009)
@@ -0,0 +1,431 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008. 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_TRAITS__HPP
+#define BOOST_SYNCHRO_LOCKABLE_TRAITS__HPP
+
+#include "boost/type_traits.hpp"
+#include "boost/mpl/or.hpp"
+#include <boost/synchro/lockable_scope_traits.hpp>
+
+namespace boost { namespace synchro {
+
+
+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 lock_traits_base or
+ * have a nested type scope or
+ * specialize the scope_tag template class
+ */
+
+//[scope_tag
+template <typename Lockable>
+struct scope_tag {
+ 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
+ : is_same_or_is_base_and_derived<
+ mono_threaded_tag,
+ typename scope_tag<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
+ : is_same_or_is_base_and_derived<
+ multi_threaded_tag,
+ typename scope_tag<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
+ : is_same_or_is_base_and_derived<
+ multi_process_tag,
+ typename scope_tag<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 lock_traits_base or
+ * have a nested type lifetime or
+ * specialize the lifetime_tag template class
+ */
+
+template <typename Lockable>
+struct lifetime_tag {
+ 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 lock_traits_base or
+ * have a nested type naming or
+ * specialize the naming_tag template class
+ */
+
+template <typename Lockable>
+struct naming_tag {
+ 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 lock_traits_base or
+ * have a nested type category or
+ * specialize the category_tag template class
+ */
+
+template <typename Lockable>
+struct category_tag {
+ 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
+ : is_same_or_is_base_and_derived<
+ exclusive_lock_tag,
+ typename category_tag<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
+ : is_same_or_is_base_and_derived<
+ sharable_lock_tag,
+ typename category_tag<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
+ : is_same_or_is_base_and_derived<
+ upgradable_lock_tag,
+ typename category_tag<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 lock_traits_base or
+ * have a nested type reentrancy or
+ * specialize the reentrancy_tag template class
+ */
+
+template <typename Lockable>
+struct reentrancy_tag {
+ 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
+ : is_same_or_is_base_and_derived<
+ recursive_tag,
+ typename reentrancy_tag<Lockable>::type
+ >
+{};
+
+/**
+ * a timed_interface_tag forms a hierarchy
+ * hasnt_timed_interface_tag <- has_timed_interface_tag
+ */
+
+//[timed_interface_tag_hierarchy
+struct hasnt_timed_interface_tag {};
+struct has_timed_interface_tag : hasnt_timed_interface_tag {};
+//]
+/**
+ * A lockable implementer must either
+ * inherit from the helper lock_traits_base or
+ * have a nested type timed_interface or
+ * specialize the timed_interface_tag template class
+ */
+
+template <typename Lockable>
+struct timed_interface_tag {
+ typedef typename Lockable::timed_interface type;
+};
+
+/**
+ * Inherits: If Lockable has a timed_interface_tag that inherits from
+ * then has_timed_interface_tag then inherits from true_type,
+ * otherwise inherits from false_type.
+ */
+
+template <typename Lockable>
+struct has_timed_interface
+ : is_same_or_is_base_and_derived<
+ has_timed_interface_tag,
+ typename timed_interface_tag<Lockable>::type
+ >
+{};
+
+template <typename Locker>
+struct lockable_type {
+ typedef typename Locker::lockable_type 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;
+};
+
+//[lock_lockers_traits
+template <typename Lockable>
+struct scoped_lock_type {
+ typedef typename lockable_scope_traits<
+ typename scope_tag<Lockable>::type, Lockable>::scoped_lock type;
+};
+
+template <typename Lockable>
+struct unique_lock_type {
+ typedef typename lockable_scope_traits<
+ typename scope_tag<Lockable>::type, Lockable>::unique_lock type;
+};
+
+template <typename Lockable>
+struct shared_lock_type {
+ typedef typename lockable_scope_traits<
+ typename scope_tag<Lockable>::type, Lockable>::shared_lock type;
+};
+
+template <typename Lockable>
+struct upgrade_lock_type {
+ typedef typename lockable_scope_traits<
+ typename scope_tag<Lockable>::type, Lockable>::upgrade_lock type;
+};
+//]
+
+//[lock_exception_traits
+template <typename Lockable>
+struct lock_error_type {
+ typedef typename lockable_scope_traits<
+ typename scope_tag<Lockable>::type, Lockable
+ >::lock_error type;
+};
+//]
+
+//[lock_movable_traits
+template <typename Lockable>
+struct move_object_type {
+ template <typename T>
+ struct moved_object : lockable_scope_traits<
+ typename scope_tag<Lockable>::type, Lockable>::template moved_object<T> {
+ moved_object(T& t_): lockable_scope_traits<
+ typename scope_tag<Lockable>::type, Lockable>::template moved_object<T>(t_) {}
+ };
+};
+//]
+//[lockers_init_traits
+template <typename Lockable>
+struct defer_lock_type {
+ typedef typename lockable_scope_traits<
+ typename scope_tag<Lockable>::type, Lockable>::defer_lock_t type;
+ static const type& value() {return lockable_scope_traits<
+ typename scope_tag<Lockable>::type, Lockable>::defer_lock();}
+};
+
+template <typename Lockable>
+struct adopt_lock_type {
+ typedef typename lockable_scope_traits<
+ typename scope_tag<Lockable>::type, Lockable>::adopt_lock_t type;
+ static const type& value(){return lockable_scope_traits<
+ typename scope_tag<Lockable>::type, Lockable>::adopt_lock();}
+};
+
+template <typename Lockable>
+struct try_to_lock_type {
+ typedef typename lockable_scope_traits<
+ typename scope_tag<Lockable>::type, Lockable>::try_to_lock_t type;
+ static const type& value(){return lockable_scope_traits<
+ typename scope_tag<Lockable>::type, Lockable>::try_to_lock();}
+};
+
+//]
+
+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;
+};
+
+//[lock_traits_base_defaults
+template<
+ typename Scope=multi_threaded_tag,
+ typename Category=exclusive_lock_tag,
+ typename Reentrancy=non_recursive_tag,
+ typename TimedInterface=has_timed_interface_tag,
+ typename Lifetime=typename default_lifetime<Scope>::type,
+ typename Naming=anonymous_tag,
+ typename Base=void
+> struct lock_traits_base;
+//]
+/**
+ * lock_traits_base is helper class that servs as a base class of lockables.
+ */
+
+//[lock_traits_base
+template<
+ typename Scope,
+ typename Category,
+ typename Reentrancy,
+ typename TimedInterface,
+ typename Lifetime,
+ typename Naming,
+ typename Base
+>
+struct lock_traits_base : Base {
+ // TODO add constraints on typenames
+ typedef Scope scope;
+ typedef Category category;
+ typedef Reentrancy reentrancy;
+ typedef TimedInterface timed_interface;
+ typedef Lifetime lifetime;
+ typedef Naming naming;
+};
+//]
+
+//[lock_traits_base_void
+template<
+ typename Scope,
+ typename Category,
+ typename Reentrancy,
+ typename TimedInterface,
+ typename Lifetime,
+ typename Naming
+>
+struct lock_traits_base<Scope, Category, Reentrancy, TimedInterface, Lifetime, Naming, void> {
+ typedef Scope scope;
+ typedef Category category;
+ typedef Reentrancy reentrancy;
+ typedef TimedInterface timed_interface;
+ typedef Lifetime lifetime;
+ typedef Naming naming;
+};
+//]
+
+
+}
+}
+
+
+#endif
+

Added: sandbox/synchro/boost/synchro/locker_concepts.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/synchro/locker_concepts.hpp 2009-02-09 17:25:26 EST (Mon, 09 Feb 2009)
@@ -0,0 +1,60 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008. 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_LOCKER_CONCEPTS_HPP
+#define BOOST_SYNCHRO_LOCKER_CONCEPTS_HPP
+
+#include "boost/synchro/lockable_traits.hpp"
+#include <boost/date_time/posix_time/ptime.hpp>
+#include <boost/concept_check.hpp>
+namespace boost { namespace synchro {
+
+/**
+ * LockerConcept 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
+ */
+
+template <typename Locker>
+struct LockerConcept {
+ typedef typename lockable_type<Locker>::type lockable_type;
+ BOOST_CONCEPT_USAGE(LockerConcept) {
+ Locker l(mtx_);
+ }
+ lockable_type mtx_;
+};
+
+
+/**
+ * MovableLockerConcept object extends LockerConcept
+ * with the timed_lock function
+ */
+
+template <typename Locker>
+struct MovableLockerConcept {
+ typedef typename lockable_type<Locker>::type lockable_type;
+ BOOST_CONCEPT_ASSERT((LockerConcept<lockable_type>));
+
+ BOOST_CONCEPT_USAGE(MovableLockerConcept) {
+ Locker l1(mtx_);
+ Locker& l2(l1);
+ Locker l3(l1.move());
+ BOOST_ASSERT((l2.mutex()!=&mtx_));
+ l3.lock();
+ l2 = l3.move();
+ }
+ lockable_type mtx_;
+};
+
+
+}
+}
+#endif

Added: sandbox/synchro/boost/synchro/make_lockable.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/synchro/make_lockable.hpp 2009-02-09 17:25:26 EST (Mon, 09 Feb 2009)
@@ -0,0 +1,146 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008. 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_MAKE_LOCKABLE__HPP
+#define BOOST_SYNCHRO_MAKE_LOCKABLE__HPP
+
+#include <boost/synchro/lockable_traits.hpp>
+#include "boost/noncopyable.hpp"
+#include "boost/thread/thread_time.hpp"
+
+namespace boost { namespace synchro {
+
+//[make_exclusive_lockable
+template <typename Lockable>
+class make_exclusive_lockable : private boost::noncopyable
+{
+public:
+ typedef Lockable lockable_type;
+ typedef typename scope_tag<Lockable>::type scope;
+ typedef typename category_tag<Lockable>::type category;
+ typedef typename reentrancy_tag<Lockable>::type reentrancy;
+ typedef typename timed_interface_tag<Lockable>::type timed_interface;
+ typedef typename lifetime_tag<Lockable>::type lifetime;
+ typedef typename naming_tag<Lockable>::type naming;
+
+
+ void lock() {lock_.lock();}
+ void unlock() {lock_.unlock();}
+ bool try_lock() { return lock_.try_lock();}
+ lockable_type* mutex() const { return &lock_; }
+
+protected:
+ mutable Lockable lock_;
+};
+//]
+
+//[make_timed_lockable
+template <typename TimedLock>
+class make_timed_lockable
+ : public make_exclusive_lockable<TimedLock>
+{
+public:
+ typedef TimedLock lockable_base_type;
+
+ bool timed_lock(system_time const & abs_time)
+ {return the_lock().timed_lock(abs_time);}
+ template<typename TimeDuration>
+ bool timed_lock(TimeDuration const & relative_time)
+ {return the_lock().timed_lock(relative_time);}
+protected:
+ TimedLock& the_lock() {return *static_cast<TimedLock*>(&this->lock_);}
+};
+//]
+
+//[make_share_lockable
+template <typename SharableLock>
+class make_share_lockable
+ : public make_timed_lockable<SharableLock>
+{
+public:
+ typedef SharableLock lockable_base_type;
+
+ void lock_shared()
+ {the_lock().lock_shared();}
+ bool try_lock_shared()
+ {return the_lock().try_lock_shared();}
+ void unlock_shared()
+ {the_lock().unlock_shared();}
+ bool timed_lock_shared(system_time const& t)
+ {return the_lock().timed_lock_shared(t);}
+
+protected:
+ SharableLock& the_lock() {return *static_cast<SharableLock*>(&this->lock_);}
+};
+//]
+
+//[make_upgrade_lockable
+template <typename UpgradableLock>
+class make_upgrade_lockable
+ : public make_share_lockable<UpgradableLock>
+{
+public:
+ typedef UpgradableLock lockable_base_type;
+
+ void lock_upgrade()
+ {the_lock().lock_upgrade();}
+
+ void unlock_upgrade()
+ {the_lock().unlock_upgrade();}
+
+ void unlock_upgrade_and_lock()
+ {the_lock().unlock_upgrade_and_lock();}
+ void unlock_and_lock_upgrade()
+ {the_lock().unlock_and_lock_upgrade();}
+ void unlock_and_lock_shared()
+ {the_lock().unlock_and_lock_shared();}
+ void unlock_upgrade_and_lock_shared()
+ {the_lock().unlock_upgrade_and_lock_shared();}
+ bool timed_lock_upgrade(system_time const&t)
+ {return the_lock().timed_lock_upgrade(t);}
+
+protected:
+ UpgradableLock& the_lock() {return *static_cast<UpgradableLock*>(&this->lock_);}
+};
+//]
+
+
+//[make_lockable
+template <
+ typename Lockable
+ , typename category=typename category_tag<Lockable>::type
+ , typename timed_interface=typename timed_interface_tag<Lockable>::type
+> struct make_lockable;
+
+template <typename Lockable>
+struct make_lockable<Lockable, exclusive_lock_tag, hasnt_timed_interface_tag>
+ : protected make_exclusive_lockable<Lockable>
+{};
+
+template <typename Lockable>
+struct make_lockable<Lockable, exclusive_lock_tag, has_timed_interface_tag>
+ : protected make_timed_lockable<Lockable>
+{};
+
+template <typename Lockable, typename timed_interface>
+struct make_lockable<Lockable, sharable_lock_tag, timed_interface>
+ : protected make_share_lockable<Lockable>
+{};
+
+template <typename Lockable, typename timed_interface>
+struct make_lockable<Lockable, upgradable_lock_tag, timed_interface>
+ : protected make_upgrade_lockable<Lockable>
+{};
+
+//]
+
+}
+}
+#endif

Added: sandbox/synchro/boost/synchro/monitor.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/synchro/monitor.hpp 2009-02-09 17:25:26 EST (Mon, 09 Feb 2009)
@@ -0,0 +1,131 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008. 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_CONC_MONITOR__HPP
+#define BOOST_SYNCHRO_CONC_MONITOR__HPP
+
+#include "boost/synchro/lockers/condition_locker.hpp"
+#include "boost/synchro/lockable_concepts.hpp"
+#include "boost/synchro/make_lockable.hpp"
+#include "boost/synchro/thread/mutex.hpp"
+#include "boost/synchro/thread/shared_mutex.hpp"
+
+namespace boost { namespace synchro {
+
+/**
+ */
+#if 0
+//[monitor_1st_Synopsis
+template <
+ typename Lockable=boost::mutex
+>
+class exclusive_monitor : protected make_exclusive_lockable<Lockable> { /*< behaves like an ExclusiveLockable for the derived classes >*/
+protected:
+ typedef unspecified synchronizer; /*< is an strict lock guard >*/
+};
+//]
+#endif
+
+#if 0
+//[exclusive_monitor
+template <
+ typename Lockable=boost::mutex,
+ class Condition=typename best_condition<Lockable>::type
+>
+class exclusive_monitor : protected make_lockable<Lockable> {
+ BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
+protected:
+ typedef Condition condition;
+ typedef condition_unique_locker<Lockable, Condition> synchronizer;
+};
+//]
+
+//[shared_monitor
+template <
+ typename Lockable=boost::shared_mutex,
+ class Condition=condition_safe<typename best_condition_any<Lockable>::type >,
+>
+class shared_monitor : protected make_lockable<Lockable> {
+ BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
+protected:
+ typedef Condition condition;
+ typedef condition_unique_locker<Lockable, Condition> synchronizer;
+ typedef condition_shared_locker<Lockable, Condition> shared_synchronizer;
+};
+//]
+
+#endif
+
+template <
+ typename Lockable=boost::mutex,
+ class Condition=condition_safe<typename best_condition<Lockable>::type >,
+ class ConditionBoosted=condition_safe_boosted<typename best_condition<Lockable>::type >
+>
+class exclusive_monitor : protected make_lockable<Lockable> {
+ BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
+protected:
+ typedef Condition condition;
+ typedef ConditionBoosted condition_boosted;
+ typedef condition_unique_locker<Lockable, Condition, ConditionBoosted> synchronizer;
+};
+
+template <
+ typename Lockable=boost::shared_mutex,
+ class Condition=condition_safe<typename best_condition_any<Lockable>::type >,
+ class ConditionBoosted=condition_safe_boosted<typename best_condition_any<Lockable>::type >
+>
+class shared_monitor : protected make_lockable<Lockable> {
+ BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
+protected:
+ typedef Condition condition;
+ typedef ConditionBoosted condition_boosted;
+ typedef condition_unique_locker<Lockable, Condition, ConditionBoosted> synchronizer;
+ typedef condition_shared_locker<Lockable, Condition, ConditionBoosted> shared_synchronizer;
+};
+
+//[shared_monitor2
+//template <
+// typename Lockable=boost::shared_mutex,
+// typename Condition=condition_safe<best_condition<Lockable> >
+//>
+//class upgrade_monitor : protected make_lockable<Lockable> {
+// BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
+//protected:
+// typedef Condition condition;
+// typedef condition_unique_locker<Lockable, Condition> synchronizer;
+// typedef condition_shared_locker<Lockable, Condition> shared_synchronizer;
+// typedef condition_upgrade_locker<Lockable, Condition> upgrade_synchronizer;
+//};
+//]
+
+//[monitor
+template <
+ typename Lockable=boost::mutex
+ , typename lock_tag=typename category_tag<Lockable>::type
+> struct monitor;
+
+template <typename Lockable>
+struct monitor<Lockable, exclusive_lock_tag>
+ : protected exclusive_monitor<Lockable>
+{};
+
+template <typename Lockable>
+struct monitor<Lockable, sharable_lock_tag>
+ : protected shared_monitor<Lockable>
+{};
+
+template <typename Lockable>
+struct monitor<Lockable, upgradable_lock_tag>
+ : protected shared_monitor<Lockable>
+{};
+//]
+}
+}
+#endif

Added: sandbox/synchro/boost/synchro/null_condition.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/synchro/null_condition.hpp 2009-02-09 17:25:26 EST (Mon, 09 Feb 2009)
@@ -0,0 +1,85 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008. 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_NULL_CONDITION__HPP
+#define BOOST_SYNCHRO_NULL_CONDITION__HPP
+
+//!\file
+//!Describes null_mutex class
+#include <boost/synchro/null_mutex.hpp>
+
+namespace boost {
+
+namespace posix_time
+{ class ptime; }
+
+namespace synchro {
+
+class null_condition
+{
+public:
+ /// @cond
+ //Non-copyable
+ null_condition(const null_condition &);
+ null_condition &operator=(const null_condition &);
+ /// @endcond
+ 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_SYNCHRO_NULL_CONDITION__HPP

Added: sandbox/synchro/boost/synchro/null_mutex.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/synchro/null_mutex.hpp 2009-02-09 17:25:26 EST (Mon, 09 Feb 2009)
@@ -0,0 +1,157 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008. 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_NULL_CONDITION_HPP
+#define BOOST_SYNCHRO_NULL_CONDITION_HPP
+
+
+#include <boost/synchro/lockable_traits.hpp>
+#include "boost/thread/thread_time.hpp"
+
+//!\file
+//!Describes null_mutex classes
+
+namespace boost {
+
+namespace posix_time
+{ class ptime; }
+
+namespace synchro {
+class null_condition;
+//!Implements a mutex that simulates a mutex without doing any operation and
+//!simulates a successful operation.
+class null_mutex
+: public lock_traits_base<
+ mono_threaded_tag,
+ upgradable_lock_tag,
+ recursive_tag,
+ has_timed_interface_tag, void
+>
+{
+ /// @cond
+ null_mutex(const null_mutex&);
+ null_mutex &operator= (const null_mutex&);
+ /// @endcond
+public:
+ typedef null_condition condition_type;
+ typedef null_condition 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 timed_lock(const boost::posix_time::ptime &)
+ { return true; }
+
+// bool timed_lock(system_time const & abs_time)
+// {return true;}
+ template<typename TimeDuration>
+ bool timed_lock(TimeDuration const & relative_time)
+ {return true;}
+
+
+ //!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 timed_lock_share() operation.
+ //!Equivalent to "return true;"
+ bool timed_lock_shared(const boost::posix_time::ptime &)
+ { return true; }
+
+ //!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 timed_lock_upgrade() operation.
+ //!Equivalent to "return true;"
+ bool timed_lock_upgrade(boost::posix_time::ptime const &)
+ { 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 timed_unlock_upgrade_and_lock().
+ //!Equivalent to "return true;"
+ bool timed_unlock_upgrade_and_lock(const boost::posix_time::ptime &)
+ { 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_SYNCHRO_NULL_MUTEX_HPP

Added: sandbox/synchro/boost/synchro/null_synchronization_family.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/synchro/null_synchronization_family.hpp 2009-02-09 17:25:26 EST (Mon, 09 Feb 2009)
@@ -0,0 +1,36 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008. 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_NULL_SYNCHROHRONIZATION_FAMILY__HPP
+#define BOOST_SYNCHRO_NULL_SYNCHROHRONIZATION_FAMILY__HPP
+
+#include "boost/synchro/null_mutex.hpp"
+#include "boost/synchro/null_condition.hpp"
+
+namespace boost {
+namespace synchro {
+
+//!Describes interprocess_mutex family to use with Sync frameworks
+//!based on null operation synchronization objects.
+struct null_synchronization_family
+{
+ typedef boost::synchro::null_mutex mutex_type;
+ typedef boost::synchro::null_mutex recursive_mutex_type;
+ typedef boost::synchro::null_mutex timed_mutex_type;
+ typedef boost::synchro::null_mutex recursive_timed_mutex_type;
+ typedef boost::synchro::null_mutex shared_mutex_type;
+ typedef boost::synchro::null_condition condition_type;
+ typedef boost::synchro::null_condition condition_any_type;
+};
+
+}
+}
+
+#endif

Added: sandbox/synchro/boost/synchro/process_synchronization_family.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/synchro/process_synchronization_family.hpp 2009-02-09 17:25:26 EST (Mon, 09 Feb 2009)
@@ -0,0 +1,39 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008. 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_PROCESS_SYNCHROHRONIZATION_FAMILY__HPP
+#define BOOST_SYNCHRO_PROCESS_SYNCHROHRONIZATION_FAMILY__HPP
+
+#include "boost/synchro/process/mutex.hpp"
+#include "boost/synchro/process/recursive_mutex.hpp"
+#include "boost/synchro/process/upgradable_mutex.hpp"
+#include "boost/interprocess/sync/interprocess_condition.hpp"
+
+namespace boost {
+namespace synchro {
+
+
+//!Describes interprocess_mutex family to use with Sync framework
+//!based on boost::interprocess synchronization objects.
+struct process_synchronization_family
+{
+ typedef boost::synchro::interprocess_mutex mutex_type;
+ typedef boost::synchro::interprocess_recursive_mutex recursive_mutex_type;
+ typedef boost::synchro::interprocess_mutex timed_mutex_type;
+ typedef boost::synchro::interprocess_recursive_mutex recursive_timed_mutex_type;
+ typedef boost::synchro::interprocess_upgradable_mutex shared_mutex_type;
+ typedef boost::interprocess::interprocess_condition condition_type;
+ typedef boost::interprocess::interprocess_condition condition_any_type;
+};
+
+}
+}
+
+#endif

Added: sandbox/synchro/boost/synchro/semaphore.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/synchro/semaphore.hpp 2009-02-09 17:25:26 EST (Mon, 09 Feb 2009)
@@ -0,0 +1,143 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2005-2008.
+// (C) Copyright Vicente J. Botet Escriba 2008.
+// 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_SEMAPHORE_HPP
+#define BOOST_SYNCHRO_SEMAPHORE_HPP
+
+//#include "boost/thread/mutex.hpp"
+//#include "boost/thread/condition_variable.hpp"
+//#include "boost/thread/locks.hpp"
+#include "boost/synchro/thread_synchronization_family.hpp"
+#include "boost/synchro/lockable_traits.hpp"
+
+//!\file
+//!Describes a semaphore class for inter-process synchronization
+
+namespace boost {
+
+namespace synchro {
+
+//!Wraps a semaphore that can be placed in shared memory and can be
+//!shared between processes. Allows timed lock tries
+template <typename Sync=thread_synchronization_family>
+class basic_semaphore
+{
+ typedef typename Sync::mutex_type lockable_type;
+ typedef typename Sync::condition_type condition_variable;
+ typedef typename scoped_lock_type<lockable_type>::type scoped_lock;
+ typedef basic_semaphore this_type;
+
+ /// @cond
+ //Non-copyable
+ basic_semaphore(const this_type &);
+ this_type& operator=(const this_type &);
+ /// @endcond
+public:
+
+ //!Creates a semaphore with the given initial count.
+ //!exception if there is an error.*/
+ inline basic_semaphore(int initialCount);
+
+ //!Destroys the semaphore.
+ //!Does not throw
+ inline ~basic_semaphore();
+
+ //!Increments the semaphore count. If there are processes/threads blocked waiting
+ //!for the semaphore, then one of these processes will return successfully from
+ //!its wait function. If there is an error an exception exception is thrown.
+ inline void post();
+
+ //!Decrements the semaphore. If the semaphore value is not greater than zero,
+ //!then the calling process/thread blocks until it can decrement the counter.
+ //!If there is an error an exception exception is thrown.
+ inline void wait();
+
+ //!Decrements the semaphore if the semaphore's value is greater than zero
+ //!and returns true. If the value is not greater than zero returns false.
+ //!If there is an error an exception exception is thrown.
+ inline bool try_wait();
+
+ //!Decrements the semaphore if the semaphore's value is greater
+ //!than zero and returns true. Otherwise, waits for the semaphore
+ //!to the posted or the timeout expires. If the timeout expires, the
+ //!function returns false. If the semaphore is posted the function
+ //!returns true. If there is an error throws sem_exception
+ inline bool wait_until(const system_time &abs_time);
+ template<typename TimeDuration>
+ inline bool wait_for(const TimeDuration &rel_time);
+
+ /// @cond
+private:
+ lockable_type m_mut;
+ condition_variable m_cond;
+ int m_count;
+ /// @endcond
+};
+
+template <typename Sync>
+inline basic_semaphore<Sync>::~basic_semaphore()
+{}
+
+template <typename Sync>
+inline basic_semaphore<Sync>::basic_semaphore(int initialCount)
+ : m_mut(), m_cond(), m_count(initialCount)
+{}
+
+template <typename Sync>
+inline void basic_semaphore<Sync>::post()
+{
+ scoped_lock lock(m_mut);
+ if(m_count == 0){
+ m_cond.notify_one();
+ }
+ ++m_count;
+}
+
+template <typename Sync>
+inline void basic_semaphore<Sync>::wait()
+{
+ scoped_lock lock(m_mut);
+ while(m_count == 0){
+ m_cond.wait(lock);
+ }
+ --m_count;
+}
+
+template <typename Sync>
+inline bool basic_semaphore<Sync>::try_wait()
+{
+ scoped_lock lock(m_mut);
+ if(m_count == 0){
+ return false;
+ }
+ --m_count;
+ return true;
+}
+
+template <typename Sync>
+inline bool basic_semaphore<Sync>::wait_until(const system_time &abs_time)
+{
+ scoped_lock lock(m_mut);
+ while(m_count == 0){
+ if(!m_cond.timed_wait(lock, abs_time))
+ return m_count != 0;
+ }
+ --m_count;
+ return true;
+}
+
+typedef basic_semaphore<> semaphore;
+
+}
+}
+
+#endif //BOOST_SYNCHRO_SEMAPHORE_HPP

Added: sandbox/synchro/boost/synchro/syntactic_lock_traits.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/boost/synchro/syntactic_lock_traits.hpp 2009-02-09 17:25:26 EST (Mon, 09 Feb 2009)
@@ -0,0 +1,27 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008. 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_SYNTACTIC_LOCK_TRAITS__HPP
+#define BOOST_SYNCHRO_SYNTACTIC_LOCK_TRAITS__HPP
+
+#include "boost/synchro/lockable_scope_traits.hpp"
+#include "boost/synchro/lockable_traits.hpp"
+
+namespace boost { namespace synchro {
+
+//[syntactic_lock_traits
+template<typename Lockable>
+struct syntactic_lock_traits
+: lockable_scope_traits<typename scope_tag<Lockable>::type, Lockable> {};
+//]
+}
+}
+
+#endif


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