|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51235 - in sandbox/synchro/boost/synchro: . lockers poly process queues thread
From: vicente.botet_at_[hidden]
Date: 2009-02-13 05:03:48
Author: viboes
Date: 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
New Revision: 51235
URL: http://svn.boost.org/trac/boost/changeset/51235
Log:
Boost.Synchro V0.0.0
Text files modified:
sandbox/synchro/boost/synchro/lockable_adapter.hpp | 32 +-
sandbox/synchro/boost/synchro/lockable_concepts.hpp | 15
sandbox/synchro/boost/synchro/lockers/condition_locker.hpp | 432 ++++++++++++---------------------------
sandbox/synchro/boost/synchro/lockers/reverse_lock.hpp | 64 -----
sandbox/synchro/boost/synchro/monitor.hpp | 38 ++-
sandbox/synchro/boost/synchro/null_condition.hpp | 10
sandbox/synchro/boost/synchro/null_mutex.hpp | 14
sandbox/synchro/boost/synchro/poly/lock_adapter.hpp | 19 +
sandbox/synchro/boost/synchro/process/mutex.hpp | 34 +++
sandbox/synchro/boost/synchro/process/named_mutex.hpp | 42 +++
sandbox/synchro/boost/synchro/process/named_recursive_mutex.hpp | 42 +++
sandbox/synchro/boost/synchro/process/named_upgradable_mutex.hpp | 90 ++++---
sandbox/synchro/boost/synchro/process/recursive_mutex.hpp | 39 +++
sandbox/synchro/boost/synchro/process/upgradable_mutex.hpp | 18 +
sandbox/synchro/boost/synchro/queues/synchro_buffer_family.hpp | 9
sandbox/synchro/boost/synchro/semaphore.hpp | 2
sandbox/synchro/boost/synchro/thread/locks.hpp | 1
sandbox/synchro/boost/synchro/thread/mutex.hpp | 105 ++++++++-
sandbox/synchro/boost/synchro/thread/recursive_mutex.hpp | 66 ++++++
sandbox/synchro/boost/synchro/thread/shared_mutex.hpp | 38 +++
20 files changed, 612 insertions(+), 498 deletions(-)
Modified: sandbox/synchro/boost/synchro/lockable_adapter.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/lockable_adapter.hpp (original)
+++ sandbox/synchro/boost/synchro/lockable_adapter.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -30,13 +30,12 @@
typedef typename lifetime_tag<Lockable>::type lifetime;
typedef typename naming_tag<Lockable>::type naming;
-
+ exclusive_lockable_adapter() {}
void lock() {lock_.lock();}
void unlock() {lock_.unlock();}
bool try_lock() { return lock_.try_lock();}
- lockable_type* mutex() const { return &lock_; }
-
protected:
+ lockable_type* mutex() const { return &lock_; }
mutable Lockable lock_;
};
//]
@@ -49,11 +48,13 @@
public:
typedef TimedLock lockable_base_type;
- bool timed_lock(system_time const & abs_time)
- {return the_lock().timed_lock(abs_time);}
+ timed_lockable_adapter() {}
+
+ bool try_lock_until(system_time const & abs_time)
+ {return the_lock().try_lock_until(abs_time);}
template<typename TimeDuration>
- bool timed_lock(TimeDuration const & relative_time)
- {return the_lock().timed_lock(relative_time);}
+ bool try_lock_for(TimeDuration const & relative_time)
+ {return the_lock().try_lock_for(relative_time);}
protected:
TimedLock& the_lock() {return *static_cast<TimedLock*>(&this->lock_);}
};
@@ -67,14 +68,16 @@
public:
typedef SharableLock lockable_base_type;
+ shared_lockable_adapter() {}
+
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);}
+ bool try_lock_shared_until(system_time const& t)
+ {return the_lock().try_lock_shared_until(t);}
protected:
SharableLock& the_lock() {return *static_cast<SharableLock*>(&this->lock_);}
@@ -89,9 +92,16 @@
public:
typedef UpgradableLock lockable_base_type;
+ upgrade_lockable_adapter() {}
+
void lock_upgrade()
{the_lock().lock_upgrade();}
+ bool try_lock_upgrade()
+ { return the_lock().try_lock_upgrade(); }
+
+
+
void unlock_upgrade()
{the_lock().unlock_upgrade();}
@@ -103,8 +113,8 @@
{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);}
+ bool try_lock_upgrade_until(system_time const&t)
+ {return the_lock().try_lock_upgrade_until(t);}
protected:
UpgradableLock& the_lock() {return *static_cast<UpgradableLock*>(&this->lock_);}
Modified: sandbox/synchro/boost/synchro/lockable_concepts.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/lockable_concepts.hpp (original)
+++ sandbox/synchro/boost/synchro/lockable_concepts.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -44,7 +44,7 @@
//]
/**
* TimedLockableConcept object extends ExclusiveLockConcept
- * with the timed_lock function
+ * with the try_lock_until and try_lock_for functions
*/
//[TimedLockableConcept
@@ -53,8 +53,8 @@
BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
BOOST_CONCEPT_USAGE(TimedLockableConcept) {
- l.timed_lock(t);
-// l.timed_lock(1);
+ l.try_lock_until(t);
+// l.try_lock_for(1);
}
Lockable l;
system_time t;
@@ -63,7 +63,7 @@
/**
* ShareLockableConcept object extends ExclusiveTimedLockConcept
- * with the lock_shared, timed_lock_shared, try_lock_shared
+ * with the lock_shared, try_lock_shared_until, try_lock_shared
* and unlock_shared functions
*/
//[ShareLockableConcept
@@ -73,7 +73,7 @@
BOOST_CONCEPT_USAGE(ShareLockableConcept) {
l.lock_shared();
- l.timed_lock_shared(t);
+ l.try_lock_shared_until(t);
l.try_lock_shared();
l.unlock_shared();
}
@@ -85,7 +85,7 @@
/**
* UpgradeLockableConcept object extends SharableLockableConcept
- * with the lock_upgrade, timed_lock_upgrade, unlock_upgrade_and_lock,
+ * with the lock_upgrade, lock_upgrade_until, unlock_upgrade_and_lock,
* unlock_and_lock_shared and unlock_upgrade_and_lock_shared functions
*/
@@ -96,7 +96,8 @@
BOOST_CONCEPT_USAGE(UpgradeLockableConcept) {
l.lock_upgrade();
- l.timed_lock_upgrade(t);
+ l.try_lock_upgrade();
+ // l.try_lock_upgrade_until(t);
l.unlock_upgrade_and_lock();
l.unlock_and_lock_upgrade();
l.unlock_and_lock_shared();
Modified: sandbox/synchro/boost/synchro/lockers/condition_locker.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/lockers/condition_locker.hpp (original)
+++ sandbox/synchro/boost/synchro/lockers/condition_locker.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -14,193 +14,22 @@
#include <boost/synchro/lockable_concepts.hpp>
#include <boost/thread/condition.hpp>
#include <boost/synchro/thread/mutex.hpp>
+#include <boost/synchro/condition_backdoor.hpp>
+#include <boost/synchro/condition_safe.hpp>
namespace boost { namespace synchro {
-
-
-template <
- class Condition
->
-class condition_backdoor;
-
-template <
- class Condition
->
-class condition_safe_boosted {
-public:
- typedef Condition condition;
- typedef condition_backdoor<Condition> backdoor;
- friend class condition_backdoor<Condition>;
-private:
- template <typename Locker>
- void notify_one(Locker& lock) {
- ++num_notifies_requested;
- if (num_blocked > 0) {
- cond_.notify_one();
- ++num_notifies_done;
- }
- }
- template <typename Locker>
- void notify_all(Locker& lock) {
- ++num_notifies_requested;
- if (num_blocked > 0) {
- cond_.notify_all();
- ++num_notifies_done;
- }
- }
- template <typename Locker, typename Predicate>
- void wait_when(Locker& lock, Predicate pred) {
- while(!pred()) wait(lock);
- }
- template <typename Locker>
- void wait(Locker& lock) {
- ++num_waits;
- ++num_blocked;
- cond_.wait(lock);
- --num_blocked;
- }
-
- template <typename Locker>
- bool wait_until(Locker& lock, boost::system_time const& abs_time) {
- ++num_waits;
- ++num_blocked;
- bool b = cond_.timed_wait(lock);
- --num_blocked;
- return b;
- }
-
- template<typename Locker, typename duration_type>
- bool wait_for(Locker& lock,duration_type const& rel_time) {
- ++num_waits;
- ++num_blocked;
- bool b =cond_.timed_wait(lock);
- --num_blocked;
- return b;
- }
-
- template<typename Locker, typename predicate_type>
- bool wait_when_until(Locker& lock, predicate_type pred, boost::system_time const& abs_time) {
- while (!pred())
- {
- if(!wait_until(lock, abs_time))
- return pred();
- }
- return true;
- }
- template<typename Locker, typename duration_type, typename predicate_type>
- bool wait_when_for(Locker& lock, predicate_type pred, duration_type const& rel_time) {
- while (!pred())
- {
- if(!wait_for(lock, rel_time))
- return pred();
- }
- return true;
- }
-private:
- Condition cond_;
- unsigned num_blocked;
- unsigned num_waits;
- unsigned num_notifies_requested;
- unsigned num_notifies_done;
-};
-
-template <
- class Condition
->
-class condition_safe {
-public:
- typedef Condition condition;
- typedef condition_backdoor<Condition> backdoor;
- void notify_one() { cond_.notify_one(); }
- void notify_all() { cond_.notify_all(); }
-private:
- friend class condition_backdoor<Condition>;
- template <typename Locker, typename Predicate>
- void wait_when(Locker& lock, Predicate pred) {
- cond_.wait(lock, pred);
- }
- template <typename Locker>
- void wait(Locker& lock) {
- cond_.wait(lock);
- }
-
- template <typename Locker>
- bool wait_until(Locker& lock, boost::system_time const& abs_time) {
- return cond_.timed_wait(lock);;
- }
-
- template<typename Locker, typename duration_type>
- bool wait_for(Locker& lock,duration_type const& rel_time) {
- return cond_.timed_wait(lock);
- }
-
-// template<typename Locker, typename predicate_type>
-// bool wait_when(Locker& lock, predicate_type pred) {
-// return cond_.wait(lock, pred);
-// }
- template<typename Locker, typename predicate_type>
- bool wait_when_until(Locker& lock, predicate_type pred, boost::system_time const& abs_time) {
- return cond_.timed_wait(lock, pred, abs_time);
- }
- template<typename Locker, typename duration_type, typename predicate_type>
- bool wait_when_for(Locker& lock, predicate_type pred, duration_type const& rel_time) {
- return cond_.timed_wait(lock, pred, rel_time);
- }
-private:
- Condition cond_;
-};
-
-template <
- class Condition
->
-struct condition_backdoor {
- condition_backdoor(condition_safe<Condition>&cnd): that_(cnd) {}
- template <typename Locker, typename Predicate>
- void wait_when(Locker& lock, Predicate pred){
- that_.wait_when(lock, pred);
- }
- template <typename Locker>
- void wait(Locker& lock) {
- that_.wait(lock);
- }
- template <typename Locker>
- bool wait_until(Locker& lock, boost::system_time const& abs_time) {
- return that_.wait_until(lock, abs_time);
- }
-
- template<typename Locker, typename duration_type>
- bool wait_for(Locker& lock, duration_type const& rel_time) {
- return that_.wait_for(lock, rel_time);
- }
-
- template<typename Locker, typename predicate_type>
- bool wait_when_until(Locker& lock, predicate_type pred, boost::system_time const& abs_time) {
- return that_.timed_wait(lock, pred, abs_time);
- }
- template <typename Locker>
- void notify_one(Locker& lock) {
- that_.notify_one(lock);
- }
- template <typename Locker>
- void notify_all(Locker& lock) {
- that_.notify_all(lock);
- }
-private:
- condition_safe<Condition>& that_;
-};
-
#if 0
//[condition_unique_locker
template <
- typename Lockable,
+ typename Lockable,
class Condition=condition_safe<typename best_condition<Lockable>::type >
>
class condition_unique_locker
- : protected unique_lock<Lockable>
+ : protected unique_lock_type<Lockable>::type
{
BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
- typedef unique_lock<Lockable> super_type;
+ typedef typename unique_lock_type<Lockable>::type super_type;
public:
typedef Lockable lockable_type;
typedef Condition condition;
@@ -226,57 +55,53 @@
void relock_when(condition &cond, Predicate pred);
template<typename Predicate>
void relock_when_until(condition &cond, Predicate pred,
- boost::system_time const& abs_time);
+ boost::system_time const& abs_time);
template<typename Predicate, typename duration_type>
void relock_when_for(condition &cond, Predicate pred,
- duration_type const& rel_time);
-
- void notify_one(condition_boosted &cond);
- void notify_all(condition_boosted &cond);
+ duration_type const& rel_time);
/*< no possibility to unlock without blocking on wait... >*/
-
};
//]
#endif
template <
- typename Lockable,
- class Condition=condition_safe<typename best_condition<Lockable>::type >,
- class ConditionBoosted=condition_safe_boosted<typename best_condition<Lockable>::type >
+ typename Lockable,
+ class Condition=condition_safe<typename best_condition<Lockable>::type >
+ //, class ConditionBoosted=condition_safe_boosted<typename best_condition<Lockable>::type >
>
class condition_unique_locker
- : protected unique_lock<Lockable>
+ : protected unique_lock_type<Lockable>::type
{
BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
- typedef unique_lock<Lockable> super_type;
+ typedef typename unique_lock_type<Lockable>::type super_type;
public:
typedef Lockable lockable_type;
typedef Condition condition;
- typedef ConditionBoosted condition_boosted;
+ //typedef ConditionBoosted condition_boosted;
explicit condition_unique_locker(lockable_type& obj)
: super_type(obj) { } /*< locks on construction >*/
condition_unique_locker(lockable_type& obj, condition &cond)
: super_type(obj) {
- typename condition::backdoor(cond).wait(*static_cast<unique_lock<Lockable>*>(this)); /*< relock on condition >*/
- }
- condition_unique_locker(lockable_type& obj, condition_boosted &cond)
- : super_type(obj) {
- typename condition::backdoor(cond).wait(*static_cast<unique_lock<Lockable>*>(this)); /*< relock on condition >*/
+ typename condition::backdoor(cond).wait(*static_cast<typename unique_lock_type<Lockable>::type*>(this)); /*< relock on condition >*/
}
+ //condition_unique_locker(lockable_type& obj, condition_boosted &cond)
+ // : super_type(obj) {
+ // typename condition::backdoor(cond).wait(*static_cast<unique_lock<Lockable>*>(this)); /*< relock on condition >*/
+ // }
template <typename Predicate>
condition_unique_locker(lockable_type& obj, condition &cond, Predicate pred)
: super_type(obj) {
- typename condition::backdoor(cond).wait_when(*static_cast<unique_lock<Lockable>*>(this), pred); /*< relock condition when predicate satisfaied>*/
- }
- template <typename Predicate>
- condition_unique_locker(lockable_type& obj, condition_boosted &cond, Predicate pred)
- : super_type(obj) {
- typename condition::backdoor(cond).wait_when(*static_cast<unique_lock<Lockable>*>(this), pred); /*< relock condition when predicate satisfaied>*/
+ typename condition::backdoor(cond).wait_when(*static_cast<typename unique_lock_type<Lockable>::type*>(this), pred); /*< relock condition when predicate satisfaied>*/
}
+ //template <typename Predicate>
+ //condition_unique_locker(lockable_type& obj, condition_boosted &cond, Predicate pred)
+ // : super_type(obj) {
+ // typename condition::backdoor(cond).wait_when(*static_cast<unique_lock<Lockable>*>(this), pred); /*< relock condition when predicate satisfaied>*/
+ // }
~condition_unique_locker() { } /*< unlocks on destruction >*/
@@ -287,65 +112,65 @@
bool is_locking(lockable_type* l) const { return l==mutex(); } /*< strict lockers specific function >*/
void relock_on(condition & cond) {
- typename condition::backdoor(cond).wait(*this);
- }
- void relock_on(condition_boosted & cond) {
- typename condition::backdoor(cond).wait(*this);
+ typename condition::backdoor(cond).wait(*this);
}
+ //void relock_on(condition_boosted & cond) {
+ // typename condition::backdoor(cond).wait(*this);
+ //}
void relock_until(condition & cond, boost::system_time const& abs_time) {
- typename condition::backdoor(cond).wait_until(*this, abs_time);
- }
- void relock_until(condition_boosted & cond, boost::system_time const& abs_time) {
- typename condition::backdoor(cond).wait_until(*this, abs_time);
+ typename condition::backdoor(cond).wait_until(*this, abs_time);
}
+ //void relock_until(condition_boosted & cond, boost::system_time const& abs_time) {
+ // typename condition::backdoor(cond).wait_until(*this, abs_time);
+ //}
template<typename duration_type>
void relock_on_for(condition & cond, duration_type const& rel_time) {
- typename condition::backdoor(cond).wait_for(*this, rel_time);
- }
- template<typename duration_type>
- void relock_on_for(condition_boosted & cond, duration_type const& rel_time) {
- typename condition::backdoor(cond).wait_for(*this, rel_time);
+ typename condition::backdoor(cond).wait_for(*this, rel_time);
}
+ //template<typename duration_type>
+ //void relock_on_for(condition_boosted & cond, duration_type const& rel_time) {
+ // typename condition::backdoor(cond).wait_for(*this, rel_time);
+ //}
template<typename Predicate>
void relock_when(condition &cond, Predicate pred){
- typename condition::backdoor(cond).wait_when(*this, pred);
- }
- template<typename Predicate>
- void relock_when(condition_boosted &cond, Predicate pred){
- typename condition::backdoor(cond).wait_when(*this, pred);
+ typename condition::backdoor(cond).wait_when(*this, pred);
}
+ //template<typename Predicate>
+ //void relock_when(condition_boosted &cond, Predicate pred){
+ // typename condition::backdoor(cond).wait_when(*this, pred);
+ //}
template<typename Predicate>
void relock_when_until(condition &cond, Predicate pred,
- boost::system_time const& abs_time){
- typename condition::backdoor(cond).wait_when_until(*this, pred, abs_time);
- }
- template<typename Predicate>
- void relock_when_until(condition_boosted &cond, Predicate pred,
- boost::system_time const& abs_time){
- typename condition::backdoor(cond).wait_when_until(*this, pred, abs_time);
+ boost::system_time const& abs_time){
+ typename condition::backdoor(cond).wait_when_until(*this, pred, abs_time);
}
+ //template<typename Predicate>
+ //void relock_when_until(condition_boosted &cond, Predicate pred,
+ // boost::system_time const& abs_time){
+ // typename condition::backdoor(cond).wait_when_until(*this, pred, abs_time);
+ //}
template<typename Predicate, typename duration_type>
void relock_when_for(condition &cond, Predicate pred,
- duration_type const& rel_time){
- typename condition::backdoor(cond).wait_when_for(*this, pred, rel_time);
- }
- template<typename Predicate, typename duration_type>
- void relock_when_for(condition_boosted &cond, Predicate pred,
- duration_type const& rel_time){
- typename condition::backdoor(cond).wait_when_for(*this, pred, rel_time);
- }
-
- void notify_one(condition_boosted &cond){
- typename condition::backdoor(cond).notify_one(*this);
- }
- void notify_all(condition_boosted &cond){
- typename condition::backdoor(cond).notify_all(*this);
+ duration_type const& rel_time){
+ typename condition::backdoor(cond).wait_when_for(*this, pred, rel_time);
}
+ //template<typename Predicate, typename duration_type>
+ //void relock_when_for(condition_boosted &cond, Predicate pred,
+ // duration_type const& rel_time){
+ // typename condition::backdoor(cond).wait_when_for(*this, pred, rel_time);
+ //}
+
+ //void notify_one(condition_boosted &cond){
+ // typename condition::backdoor(cond).notify_one(*this);
+ //}
+ //void notify_all(condition_boosted &cond){
+ // typename condition::backdoor(cond).notify_all(*this);
+ //}
/*< no possibility to unlock without blocking on wait... >*/
@@ -361,39 +186,39 @@
//[condition_shared_locker
template <
- typename Lockable,
- class Condition=condition_safe<typename best_condition_any<Lockable>::type >,
- class ConditionBoosted=condition_safe_boosted<typename best_condition_any<Lockable>::type >
+ typename Lockable,
+ class Condition=condition_safe<typename best_condition_any<Lockable>::type >
+ //, class ConditionBoosted=condition_safe_boosted<typename best_condition_any<Lockable>::type >
>
class condition_shared_locker
- : protected shared_lock<Lockable> {
+ : protected shared_lock<Lockable> {
BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
typedef shared_lock<Lockable> super_type;
public:
typedef Lockable lockable_type;
typedef Condition condition;
- typedef ConditionBoosted condition_boosted;
+ //typedef ConditionBoosted condition_boosted;
explicit condition_shared_locker(lockable_type& obj)
: super_type(obj) { } /*< locks on construction >*/
condition_shared_locker(lockable_type& obj, condition &cond)
: super_type(obj) {
- typename condition::backdoor(cond).wait(*this); /*< relock on condition >*/
- }
- condition_shared_locker(lockable_type& obj, condition_boosted &cond)
- : super_type(obj) {
- typename condition::backdoor(cond).wait(*this); /*< relock on condition >*/
+ typename condition::backdoor(cond).wait(*this); /*< relock on condition >*/
}
+ //condition_shared_locker(lockable_type& obj, condition_boosted &cond)
+ // : super_type(obj) {
+ // typename condition::backdoor(cond).wait(*this); /*< relock on condition >*/
+ // }
template <typename Predicate>
condition_shared_locker(lockable_type& obj, condition &cond, Predicate pred)
: super_type(obj) {
- typename condition::backdoor(cond).wait(*this, pred); /*< relock condition when predicate satisfaied>*/
- }
- template <typename Predicate>
- condition_shared_locker(lockable_type& obj, condition_boosted &cond, Predicate pred)
- : super_type(obj) {
- typename condition::backdoor(cond).wait(*this, pred); /*< relock condition when predicate satisfaied>*/
+ typename condition::backdoor(cond).wait(*this, pred); /*< relock condition when predicate satisfaied>*/
}
+ //template <typename Predicate>
+ //condition_shared_locker(lockable_type& obj, condition_boosted &cond, Predicate pred)
+ // : super_type(obj) {
+ // typename condition::backdoor(cond).wait(*this, pred); /*< relock condition when predicate satisfaied>*/
+ // }
~condition_shared_locker() { } /*< unlocks on destruction >*/
typedef bool (condition_shared_locker::*bool_type)() const; /*< safe bool idiom >*/
@@ -403,58 +228,58 @@
bool is_locking(lockable_type* l) const { return l==mutex(); } /*< strict lockers specific function >*/
void relock_on(condition & cond) {
- typename condition::backdoor(cond).wait(*this);
- }
- void relock_on(condition_boosted & cond) {
- typename condition::backdoor(cond).wait(*this);
+ typename condition::backdoor(cond).wait(*this);
}
+ //void relock_on(condition_boosted & cond) {
+ // typename condition::backdoor(cond).wait(*this);
+ //}
void relock_until(condition & cond, boost::system_time const& abs_time) {
- typename condition::backdoor(cond).wait_until(*this, abs_time);
- }
- void relock_until(condition_boosted & cond, boost::system_time const& abs_time) {
- typename condition::backdoor(cond).wait_until(*this, abs_time);
+ typename condition::backdoor(cond).wait_until(*this, abs_time);
}
+ //void relock_until(condition_boosted & cond, boost::system_time const& abs_time) {
+ // typename condition::backdoor(cond).wait_until(*this, abs_time);
+ //}
template<typename duration_type>
void relock_on_for(condition & cond, duration_type const& rel_time) {
- typename condition::backdoor(cond).wait_for(*this, rel_time);
- }
- template<typename duration_type>
- void relock_on_for(condition_boosted & cond, duration_type const& rel_time) {
- typename condition::backdoor(cond).wait_for(*this, rel_time);
+ typename condition::backdoor(cond).wait_for(*this, rel_time);
}
+ //template<typename duration_type>
+ //void relock_on_for(condition_boosted & cond, duration_type const& rel_time) {
+ // typename condition::backdoor(cond).wait_for(*this, rel_time);
+ //}
template<typename Predicate>
void relock_when(condition &cond, Predicate pred){
- typename condition::backdoor(cond).wait_when(*this, pred);
- }
- template<typename Predicate>
- void relock_when(condition_boosted &cond, Predicate pred){
- typename condition::backdoor(cond).wait_when(*this, pred);
+ typename condition::backdoor(cond).wait_when(*this, pred);
}
+ //template<typename Predicate>
+ //void relock_when(condition_boosted &cond, Predicate pred){
+ // typename condition::backdoor(cond).wait_when(*this, pred);
+ //}
template<typename Predicate>
void relock_when_until(condition &cond, Predicate pred,
- boost::system_time const& abs_time){
- typename condition::backdoor(cond).wait_when_until(*this, pred, abs_time);
- }
- template<typename Predicate>
- void relock_when_until(condition_boosted &cond, Predicate pred,
- boost::system_time const& abs_time){
- typename condition::backdoor(cond).wait_when_until(*this, pred, abs_time);
+ boost::system_time const& abs_time){
+ typename condition::backdoor(cond).wait_when_until(*this, pred, abs_time);
}
+ //template<typename Predicate>
+ //void relock_when_until(condition_boosted &cond, Predicate pred,
+ // boost::system_time const& abs_time){
+ // typename condition::backdoor(cond).wait_when_until(*this, pred, abs_time);
+ //}
template<typename Predicate, typename duration_type>
void relock_when_for(condition &cond, Predicate pred,
- duration_type const& rel_time){
- typename condition::backdoor(cond).wait_when_for(*this, pred, rel_time);
- }
- template<typename Predicate, typename duration_type>
- void relock_when_for(condition_boosted &cond, Predicate pred,
- duration_type const& rel_time){
- typename condition::backdoor(cond).wait_when_for(*this, pred, rel_time);
+ duration_type const& rel_time){
+ typename condition::backdoor(cond).wait_when_for(*this, pred, rel_time);
}
+ //template<typename Predicate, typename duration_type>
+ //void relock_when_for(condition_boosted &cond, Predicate pred,
+ // duration_type const& rel_time){
+ // typename condition::backdoor(cond).wait_when_for(*this, pred, rel_time);
+ //}
/*< no possibility to unlock without blocking on wait>*/
@@ -472,11 +297,11 @@
//[condition_lockable
template <
- typename Lockable,
+ typename Lockable,
class Condition=condition_safe<typename best_condition<Lockable>::type >
>
class condition_lockable
- : protected Lockable
+ : public Lockable
{
BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
typedef Lockable super_type;
@@ -489,42 +314,45 @@
~condition_lockable() { }
+ //void lock();
+ //void unlock();
+ //bool try_lock();
+ //bool try_lock_until(system_time const & abs_time)
+ //{return the_lock().timed_lock(abs_time);}
+ //template<typename TimeDuration>
+ //bool try_lock_for(TimeDuration const & relative_time)
+ //{return the_lock().timed_lock(relative_time);}
+
void relock_on(condition & cond) {
- typename condition::backdoor(cond).wait(*this);
+ typename condition::backdoor(cond).wait(*this);
}
void relock_until(condition & cond, boost::system_time const& abs_time) {
- typename condition::backdoor(cond).wait_until(*this, abs_time);
+ typename condition::backdoor(cond).wait_until(*this, abs_time);
}
template<typename duration_type>
void relock_on_for(condition & cond, duration_type const& rel_time) {
- typename condition::backdoor(cond).wait_for(*this, rel_time);
+ typename condition::backdoor(cond).wait_for(*this, rel_time);
}
template<typename Predicate>
void relock_when(condition &cond, Predicate pred){
- typename condition::backdoor(cond).wait_when(*this, pred);
+ typename condition::backdoor(cond).wait_when(*this, pred);
}
template<typename Predicate>
void relock_when_until(condition &cond, Predicate pred,
- boost::system_time const& abs_time){
- typename condition::backdoor(cond).wait_when_until(*this, pred, abs_time);
+ boost::system_time const& abs_time){
+ typename condition::backdoor(cond).wait_when_until(*this, pred, abs_time);
}
template<typename Predicate, typename duration_type>
void relock_when_for(condition &cond, Predicate pred,
- duration_type const& rel_time){
- typename condition::backdoor(cond).wait_when_for(*this, pred, rel_time);
+ duration_type const& rel_time){
+ typename condition::backdoor(cond).wait_when_for(*this, pred, rel_time);
}
- void notify_one(condition &cond){
- typename condition::backdoor(cond).notify_one(*this);
- }
- void notify_all(condition &cond){
- typename condition::backdoor(cond).notify_all(*this);
- }
private:
friend class boost::condition_variable;
Modified: sandbox/synchro/boost/synchro/lockers/reverse_lock.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/lockers/reverse_lock.hpp (original)
+++ sandbox/synchro/boost/synchro/lockers/reverse_lock.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -8,8 +8,8 @@
//
//////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_SYNCHRO_IS_STRICT_LOCKER__HPP
-#define BOOST_SYNCHRO_IS_STRICT_LOCKER__HPP
+#ifndef BOOST_SYNCHRO_REVERSE_LOCKER__HPP
+#define BOOST_SYNCHRO_REVERSE_LOCKER__HPP
#include <boost/mpl/bool.hpp>
#include <boost/noncopyable.hpp>
@@ -19,67 +19,7 @@
namespace boost { namespace synchro {
-/**
- */
-
-template <typename Lockable>
-class reverse_locker
-{
- reverse_locker(Lockable& mtx): mtx_(mtx) {mtx_.unlock();}
- ~reverse_locker() {mtx_.lock();}
-
-protected:
- Lockable& mtx_;
-};
-
-
-/*
- *
- * unique_lock<mutex> lock(smtx);
- * // ... some read operations
- * { // non locked block
- * reverse_lock<unique_lock<mutex> > rlock(lock);
- * // ... some code not needing
- * } // locked again
- * // ...
- */
-template <typename Locker>
-class reverse_lock : boost::noncopyable
-{
-// BOOST_CONCEPT_ASSERT((MovableLockConcept<Locker>));
- typedef typename lock_error_type<typename lockable_type<Locker>::type >::type lock_error;
-
-public:
- explicit reverse_lock(Locker& locker)
- : locker_(locker) /*< Store reference to locker >*/
- , tmp_locker_(locker.move()) /*< Move ownership to temporaty locker >*/
- , was_locked_(false)
- {
-#ifndef BOOST_SYNCHRO_REVERSE_LOCK_DONT_CHECK_OWNERSHIP /*< Define BOOST_SYNCHRO_REVERSE_LOCK_DONT_CHECK_OWNERSHIP if you don't want to check locker ownership >*/
- if (tmp_locker_.mutex()==0) {
- locker_=tmp_locker_.move(); /*< Rollback for coherency purposes >*/
- throw lock_error();
- }
-#endif
- if (tmp_locker_) { /*< ensures it is unlocked >*/
- tmp_locker_.unlock();
- was_locked_=true;
- }
- }
- ~reverse_lock() {
- if (was_locked_) {
- tmp_locker_.lock();
- }
- locker_=tmp_locker_.move(); /*< Move ownership to nesting locker >*/
- }
-
-protected:
- Locker& locker_;
- Locker tmp_locker_;
- bool was_locked_;
- reverse_lock();
-};
/*
*
Modified: sandbox/synchro/boost/synchro/monitor.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/monitor.hpp (original)
+++ sandbox/synchro/boost/synchro/monitor.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -24,7 +24,7 @@
#if 0
//[monitor_1st_Synopsis
template <
- typename Lockable=boost::mutex
+ typename Lockable=thread_mutex
>
class exclusive_monitor : protected exclusive_lockable_adapter<Lockable> { /*< behaves like an ExclusiveLockable for the derived classes >*/
protected:
@@ -36,7 +36,7 @@
#if 0
//[exclusive_monitor
template <
- typename Lockable=boost::mutex,
+ typename Lockable=thread_mutex,
class Condition=typename best_condition<Lockable>::type
>
class exclusive_monitor : protected lockable_adapter<Lockable> {
@@ -49,7 +49,7 @@
//[shared_monitor
template <
- typename Lockable=boost::shared_mutex,
+ typename Lockable=thread_shared_mutex,
class Condition=condition_safe<typename best_condition_any<Lockable>::type >,
>
class shared_monitor : protected lockable_adapter<Lockable> {
@@ -64,35 +64,41 @@
#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 >
+ typename Lockable=thread_mutex,
+ class Condition=condition_safe<typename best_condition<Lockable>::type >
+ //, class ConditionBoosted=condition_safe_boosted<typename best_condition<Lockable>::type >
>
class exclusive_monitor : protected lockable_adapter<Lockable> {
BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
protected:
typedef Condition condition;
- typedef ConditionBoosted condition_boosted;
- typedef condition_unique_locker<Lockable, Condition, ConditionBoosted> synchronizer;
+ //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 >
+ typename Lockable=thread_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 lockable_adapter<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;
+ //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 Lockable=thread_shared_mutex,
// typename Condition=condition_safe<best_condition<Lockable> >
//>
//class upgrade_monitor : protected lockable_adapter<Lockable> {
@@ -107,7 +113,7 @@
//[monitor
template <
- typename Lockable=boost::mutex
+ typename Lockable=thread_mutex
, typename lock_tag=typename category_tag<Lockable>::type
> struct monitor;
Modified: sandbox/synchro/boost/synchro/null_condition.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/null_condition.hpp (original)
+++ sandbox/synchro/boost/synchro/null_condition.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -14,17 +14,16 @@
//!\file
//!Describes null_mutex class
#include <boost/synchro/null_mutex.hpp>
+#include <boost/thread/thread_time.hpp>
namespace boost {
-namespace posix_time
-{ class ptime; }
namespace synchro {
class null_condition
{
-public:
+private:
/// @cond
//Non-copyable
null_condition(const null_condition &);
@@ -62,15 +61,16 @@
//!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)
+ bool timed_wait(L& lock, const boost::system_time &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)
+ bool timed_wait(L& lock, const boost::system_time &abs_time, Pr pred)
{ return true; }
};
Modified: sandbox/synchro/boost/synchro/null_mutex.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/null_mutex.hpp (original)
+++ sandbox/synchro/boost/synchro/null_mutex.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -40,8 +40,8 @@
null_mutex &operator= (const null_mutex&);
/// @endcond
public:
- typedef null_condition condition_type;
- typedef null_condition condition_any_type;
+ typedef null_condition best_condition_type;
+ typedef null_condition best_condition_any_type;
//!Constructor.
//!Empty.
@@ -61,13 +61,13 @@
//!Simulates a mutex timed_lock() operation.
//!Equivalent to "return true;"
- bool timed_lock(const boost::posix_time::ptime &)
+ bool try_lock_until(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)
+ bool try_lock_for(TimeDuration const & relative_time)
{return true;}
@@ -86,7 +86,7 @@
//!Simulates a mutex timed_lock_share() operation.
//!Equivalent to "return true;"
- bool timed_lock_shared(const boost::posix_time::ptime &)
+ bool try_lock_shared_until(const boost::posix_time::ptime &)
{ return true; }
//!Simulates a mutex unlock_share() operation.
@@ -104,7 +104,7 @@
//!Simulates a mutex timed_lock_upgrade() operation.
//!Equivalent to "return true;"
- bool timed_lock_upgrade(boost::posix_time::ptime const &)
+ bool try_lock_upgrade_until(boost::posix_time::ptime const &)
{ return true; }
//!Simulates a mutex unlock_upgrade() operation.
@@ -136,7 +136,7 @@
//!Simulates timed_unlock_upgrade_and_lock().
//!Equivalent to "return true;"
- bool timed_unlock_upgrade_and_lock(const boost::posix_time::ptime &)
+ bool unlock_upgrade_and_lock_until(const boost::posix_time::ptime &)
{ return true; }
//!Simulates try_unlock_share_and_lock().
Modified: sandbox/synchro/boost/synchro/poly/lock_adapter.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/poly/lock_adapter.hpp (original)
+++ sandbox/synchro/boost/synchro/poly/lock_adapter.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -33,11 +33,28 @@
Lockable lock_;
};
+template <typename TimeLockable>
+class timed_lock_adapter
+ : public exclusive_lock_adapter<TimeLockable>
+ , public virtual timed_lock
+{
+public:
+ virtual ~timed_lock_adapter() {}
+ bool try_lock_until(boost::system_time const& abs_time)
+ {return the_lock().try_lock_until(abs_time);}
+ template<typename DurationType>
+ bool try_lock_for(DurationType const& rel_time)
+ {return try_lock_for(rel_time);}
+private:
+ TimeLockable& the_lock() {return *static_cast<SharableLock*>(&this->lock_);}
+};
+
+
//////////////////////////////////////////////////////////////////////////////
template <typename SharableLock>
class sharable_lock_adapter
- : public exclusive_lock_adapter<SharableLock>
+ : public timed_lock_adapter<SharableLock>
, public virtual sharable_lock
{
public:
Modified: sandbox/synchro/boost/synchro/process/mutex.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/process/mutex.hpp (original)
+++ sandbox/synchro/boost/synchro/process/mutex.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -18,6 +18,38 @@
namespace boost { namespace synchro {
+class interprocess_mutex
+: public lock_traits_base<
+ multi_process_tag,
+ exclusive_lock_tag,
+ non_recursive_tag,
+ has_timed_interface_tag,
+ kernel_lifetime_tag,
+ anonymous_tag,
+ boost::interprocess::interprocess_mutex
+>
+{
+
+ //Non-copyable
+ interprocess_mutex(const interprocess_mutex &);
+ interprocess_mutex &operator=(const interprocess_mutex &);
+
+public:
+
+ typedef boost::interprocess::interprocess_condition best_condition_type;
+ typedef boost::interprocess::interprocess_condition best_condition_any_type;
+
+ bool try_lock_until(system_time const & abs_time)
+ {return timed_lock(abs_time);}
+ template<typename TimeDuration>
+ bool try_lock_for(TimeDuration const & relative_time)
+ {return timed_lock(relative_time);}
+
+ //bool try_lock_shared_until(system_time const& abs_time)
+ //{return timed_lock_shared(abs_time);}
+
+};
+#if 0
typedef boost::interprocess::interprocess_mutex interprocess_mutex;
template<>
@@ -57,7 +89,7 @@
typedef boost::interprocess::interprocess_condition type;
};
-
+#endif
}
}
Modified: sandbox/synchro/boost/synchro/process/named_mutex.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/process/named_mutex.hpp (original)
+++ sandbox/synchro/boost/synchro/process/named_mutex.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -16,7 +16,43 @@
#include <boost/synchro/process/lockable_scope_traits.hpp>
namespace boost { namespace synchro {
-
+class named_mutex
+: public boost::interprocess::named_mutex,
+ public lock_traits_base<
+ multi_process_tag,
+ exclusive_lock_tag,
+ non_recursive_tag,
+ has_timed_interface_tag,
+ kernel_lifetime_tag,
+ named_tag
+>
+{
+
+ //Non-copyable
+ named_mutex(const named_mutex &);
+ named_mutex &operator=(const named_mutex &);
+ named_mutex();
+
+public:
+
+ typedef boost::interprocess::interprocess_condition best_condition_type;
+ typedef boost::interprocess::interprocess_condition best_condition_any_type;
+
+ named_mutex(interprocess::create_only_t create_only, const char *name)
+ : interprocess::named_mutex(create_only, name) {};
+ named_mutex(interprocess::open_or_create_t open_or_create, const char *name)
+ : interprocess::named_mutex(open_or_create, name) {};
+ named_mutex(interprocess::open_only_t open_only, const char *name)
+ : interprocess::named_mutex(open_only, name) {};
+
+ bool try_lock_until(system_time const & abs_time)
+ {return this->timed_lock(abs_time);}
+ template<typename TimeDuration>
+ bool try_lock_for(TimeDuration const & relative_time)
+ {return timed_lock(relative_time);}
+
+};
+#if 0
typedef boost::interprocess::named_mutex named_mutex;
template<>
@@ -57,10 +93,6 @@
};
-#if 0
-template<>
-struct syntactic_lock_traits<boost::interprocess::named_mutex>
- : syntactic_process_lock_traits<boost::interprocess::named_mutex> {};
#endif
}
Modified: sandbox/synchro/boost/synchro/process/named_recursive_mutex.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/process/named_recursive_mutex.hpp (original)
+++ sandbox/synchro/boost/synchro/process/named_recursive_mutex.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -16,7 +16,45 @@
#include <boost/synchro/process/lockable_scope_traits.hpp>
namespace boost { namespace synchro {
+class named_recursive_mutex
+: public boost::interprocess::named_recursive_mutex,
+ public lock_traits_base<
+ multi_process_tag,
+ exclusive_lock_tag,
+ recursive_tag,
+ has_timed_interface_tag,
+ kernel_lifetime_tag,
+ named_tag
+>
+{
+
+ //Non-copyable
+ named_recursive_mutex(const named_recursive_mutex &);
+ named_recursive_mutex &operator=(const named_recursive_mutex &);
+ named_recursive_mutex();
+
+public:
+
+ typedef boost::interprocess::interprocess_condition best_condition_type;
+ typedef boost::interprocess::interprocess_condition best_condition_any_type;
+
+ named_recursive_mutex(interprocess::create_only_t create_only, const char *name)
+ : interprocess::named_recursive_mutex(create_only, name) {};
+ named_recursive_mutex(interprocess::open_or_create_t open_or_create, const char *name)
+ : interprocess::named_recursive_mutex(open_or_create, name) {};
+ named_recursive_mutex(interprocess::open_only_t open_only, const char *name)
+ : interprocess::named_recursive_mutex(open_only, name) {};
+
+ bool try_lock_until(system_time const & abs_time)
+ {return this->timed_lock(abs_time);}
+ template<typename TimeDuration>
+ bool try_lock_for(TimeDuration const & relative_time)
+ {return timed_lock(relative_time);}
+
+};
+
+#if 0
typedef boost::interprocess::named_recursive_mutex named_recursive_mutex;
template<>
@@ -56,10 +94,6 @@
typedef boost::interprocess::interprocess_condition type;
};
-#if 0
-template<>
-struct syntactic_lock_traits<boost::interprocess::named_mutex>
- : syntactic_process_lock_traits<boost::interprocess::named_mutex> {};
#endif
}
Modified: sandbox/synchro/boost/synchro/process/named_upgradable_mutex.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/process/named_upgradable_mutex.hpp (original)
+++ sandbox/synchro/boost/synchro/process/named_upgradable_mutex.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -18,80 +18,86 @@
namespace boost { namespace synchro {
class interprocess_named_upgradable_mutex
- : public lock_traits_base<
+ : public interprocess::named_upgradable_mutex,
+ public lock_traits_base<
multi_process_tag,
upgradable_lock_tag,
non_recursive_tag,
has_timed_interface_tag,
kernel_lifetime_tag,
- named_tag,
- interprocess::named_upgradable_mutex
- >
+ named_tag
+ >
{
//Non-copyable
- interprocess_named_upgradable_mutex();
interprocess_named_upgradable_mutex(const interprocess_upgradable_mutex &);
interprocess_named_upgradable_mutex &operator=(const interprocess_named_upgradable_mutex &);
+ interprocess_named_upgradable_mutex();
public:
typedef boost::interprocess::interprocess_condition condition_type;
typedef boost::interprocess::interprocess_condition condition_any_type;
-#if 0
+#if 1
interprocess_named_upgradable_mutex(interprocess::create_only_t create_only, const char *name)
- : interprocess::named_upgradable_mutex(create_only, name) {};
- interprocess_named_upgradable_mutex(interprocess::open_or_create_t open_or_create, const char *name);
- : interprocess::named_upgradable_mutex(open_or_create, name) {};
+ : interprocess::named_upgradable_mutex(create_only, name) {};
+ interprocess_named_upgradable_mutex(interprocess::open_or_create_t open_or_create, const char *name)
+ : interprocess::named_upgradable_mutex(open_or_create, name) {};
interprocess_named_upgradable_mutex(interprocess::open_only_t open_only, const char *name)
- : interprocess::named_upgradable_mutex(open_only, name) {};
+ : interprocess::named_upgradable_mutex(open_only, name) {};
#endif
- void lock_shared()
- {lock_sharable();}
+ bool try_lock_until(system_time const & abs_time)
+ {return timed_lock(abs_time);}
+ template<typename TimeDuration>
+ bool try_lock_for(TimeDuration const & relative_time)
+ {return timed_lock(relative_time);}
+
+ void lock_shared()
+ {lock_sharable();}
- bool try_lock_shared()
- {return try_lock_sharable();}
+ bool try_lock_shared()
+ {return try_lock_sharable();}
- bool timed_lock_shared(const boost::posix_time::ptime &abs_time)
- {return timed_lock_sharable(abs_time);}
+ bool try_lock_shared_until(const boost::posix_time::ptime &abs_time)
+ {return timed_lock_sharable(abs_time);}
- void unlock_shared()
- {unlock_sharable();}
+ void unlock_shared()
+ {unlock_sharable();}
- void lock_upgrade()
- {lock_upgradable();}
+ void lock_upgrade()
+ {lock_upgradable();}
- bool try_lock_upgrade()
- {return try_lock_upgradable();}
+ bool try_lock_upgrade()
+ {return try_lock_upgradable();}
- bool timed_lock_upgrade(const boost::posix_time::ptime &abs_time)
- {return timed_lock_upgradable(abs_time);}
+ bool tru_lock_upgrade_until(const boost::posix_time::ptime &abs_time)
+ {return timed_lock_upgradable(abs_time);}
- void unlock_upgrade()
- {unlock_upgradable();}
+ void unlock_upgrade()
+ {unlock_upgradable();}
- void unlock_and_lock_upgrade()
- {unlock_and_lock_upgrade();}
+ void unlock_and_lock_upgrade()
+ {unlock_and_lock_upgrade();}
- void unlock_and_lock_shared()
- {unlock_and_lock_sharable();}
+ void unlock_and_lock_shared()
+ {unlock_and_lock_sharable();}
#if 0
- void unlock_upgrade_and_lock_shared();
- {unlock_upgradable_and_lock_sharable();}
+ void unlock_upgrade_and_lock_shared();
+ {unlock_upgradable_and_lock_sharable();}
#endif
- void unlock_upgrade_and_lock()
- {unlock_upgrade_and_lock();}
+ void unlock_upgrade_and_lock()
+ {unlock_upgrade_and_lock();}
- bool try_unlock_upgrade_and_lock()
- {return try_unlock_upgradable_and_lock();}
+ bool try_unlock_upgrade_and_lock()
+ {return try_unlock_upgradable_and_lock();}
#if 0
- bool timed_unlock_upgrade_and_lock(const boost::posix_time::ptime &abs_time);
- {return timed_unlock_upgradable_and_lock(abs_time);}
+ bool unlock_upgrade_and_lock_until(const boost::posix_time::ptime &abs_time);
+ {return timed_unlock_upgradable_and_lock(abs_time);}
- bool try_unlock_share_and_lock();
- {return try_unlock_sharable_and_lock();}
+ bool try_unlock_share_and_lock();
+ {return try_unlock_sharable_and_lock();}
- bool try_unlock_share_and_lock_upgrade();
- {return try_unlock_sharable_and_lock_upgradable();}
+ bool try_unlock_share_and_lock_upgrade();
+ {return try_unlock_sharable_and_lock_upgradable();}
#endif
};
Modified: sandbox/synchro/boost/synchro/process/recursive_mutex.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/process/recursive_mutex.hpp (original)
+++ sandbox/synchro/boost/synchro/process/recursive_mutex.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -17,6 +17,40 @@
namespace boost { namespace synchro {
+class interprocess_recursive_mutex
+: public lock_traits_base<
+ multi_process_tag,
+ exclusive_lock_tag,
+ recursive_tag,
+ has_timed_interface_tag,
+ kernel_lifetime_tag,
+ anonymous_tag,
+ boost::interprocess::interprocess_recursive_mutex
+>
+{
+
+ //Non-copyable
+ interprocess_recursive_mutex(const interprocess_recursive_mutex &);
+ interprocess_recursive_mutex &operator=(const interprocess_recursive_mutex &);
+
+public:
+
+ typedef boost::interprocess::interprocess_condition best_condition_type;
+ typedef boost::interprocess::interprocess_condition best_condition_any_type;
+
+ interprocess_recursive_mutex(){}
+
+ bool try_lock_until(system_time const & abs_time)
+ {return this->timed_lock(abs_time);}
+ template<typename TimeDuration>
+ bool try_lock_for(TimeDuration const & relative_time)
+ {return timed_lock(relative_time);}
+
+ //bool try_lock_shared_until(system_time const& abs_time)
+ //{return timed_lock_shared(abs_time);}
+
+};
+#if 0
typedef boost::interprocess::interprocess_recursive_mutex interprocess_recursive_mutex;
template<>
@@ -57,11 +91,6 @@
typedef boost::interprocess::interprocess_condition type;
};
-
-#if 0
-template<>
-struct syntactic_lock_traits<boost::interprocess::interprocess_recursive_mutex>
- : syntactic_process_lock_traits<boost::interprocess::interprocess_recursive_mutex> {};
#endif
}
Modified: sandbox/synchro/boost/synchro/process/upgradable_mutex.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/process/upgradable_mutex.hpp (original)
+++ sandbox/synchro/boost/synchro/process/upgradable_mutex.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -35,16 +35,22 @@
public:
- typedef boost::interprocess::interprocess_condition condition_type;
- typedef boost::interprocess::interprocess_condition condition_any_type;
+ typedef boost::interprocess::interprocess_condition condition_type;
+ typedef boost::interprocess::interprocess_condition condition_any_type;
- void lock_shared()
- {lock_sharable();}
+ bool try_lock_until(system_time const & abs_time)
+ {return timed_lock(abs_time);}
+ template<typename TimeDuration>
+ bool try_lock_for(TimeDuration const & relative_time)
+ {return timed_lock(relative_time);}
+
+ void lock_shared()
+ {lock_sharable();}
bool try_lock_shared()
{return try_lock_sharable();}
- bool timed_lock_shared(const boost::posix_time::ptime &abs_time)
+ bool try_lock_shared_until(const boost::posix_time::ptime &abs_time)
{return timed_lock_sharable(abs_time);}
void unlock_shared()
@@ -56,7 +62,7 @@
bool try_lock_upgrade()
{return try_lock_upgradable();}
- bool timed_lock_upgrade(const boost::posix_time::ptime &abs_time)
+ bool try_lock_upgrade_until(const boost::posix_time::ptime &abs_time)
{return timed_lock_upgradable(abs_time);}
void unlock_upgrade()
Modified: sandbox/synchro/boost/synchro/queues/synchro_buffer_family.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/queues/synchro_buffer_family.hpp (original)
+++ sandbox/synchro/boost/synchro/queues/synchro_buffer_family.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -11,9 +11,10 @@
#ifndef BOOST_SYNCHRO_QUEUES_SYNCHRO_BUFFER__HPP
#define BOOST_SYNCHRO_QUEUES_SYNCHRO_BUFFER__HPP
-#include <boost/thread/locks.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/condition_variable.hpp>
+//#include <boost/thread/locks.hpp>
+//#include <boost/thread/mutex.hpp>
+//#include <boost/thread/condition_variable.hpp>
+#include <boost/synchro/lockable_traits.hpp>
namespace boost { namespace synchro {
#if 0
@@ -69,7 +70,7 @@
{
typedef typename Sync::mutex_type mutex_type;
typedef typename Sync::condition_type condition_type;
- typedef typename boost::unique_lock<mutex_type> unique_lock_type;
+ typedef typename unique_lock_type<mutex_type>::type unique_lock_type;
mutex_type mtx_;
condition_type not_full_;
condition_type not_empty_;
Modified: sandbox/synchro/boost/synchro/semaphore.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/semaphore.hpp (original)
+++ sandbox/synchro/boost/synchro/semaphore.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -30,7 +30,7 @@
{
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 typename unique_lock_type<lockable_type>::type scoped_lock;
typedef basic_semaphore this_type;
/// @cond
Modified: sandbox/synchro/boost/synchro/thread/locks.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/thread/locks.hpp (original)
+++ sandbox/synchro/boost/synchro/thread/locks.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -30,6 +30,7 @@
typedef T type;
};
+
}
}
Modified: sandbox/synchro/boost/synchro/thread/mutex.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/thread/mutex.hpp (original)
+++ sandbox/synchro/boost/synchro/thread/mutex.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -21,84 +21,155 @@
namespace boost { namespace synchro {
+class thread_mutex
+: public lock_traits_base<
+ multi_threaded_tag,
+ exclusive_lock_tag,
+ non_recursive_tag,
+ hasnt_timed_interface_tag,
+ process_lifetime_tag,
+ anonymous_tag,
+ mutex
+>
+{
+
+ //Non-copyable
+ thread_mutex(const thread_mutex &);
+ thread_mutex &operator=(const thread_mutex &);
+
+public:
+ typedef boost::condition_variable best_condition_type;
+ typedef boost::condition_variable_any best_condition_any_type;
+
+ thread_mutex() : lock_traits_base<multi_threaded_tag,exclusive_lock_tag,
+ non_recursive_tag, hasnt_timed_interface_tag,
+ process_lifetime_tag,anonymous_tag,
+ mutex>()
+ {}
+};
+
+template <>
+struct unique_lock_type<thread_mutex> {
+ typedef boost::unique_lock<boost::mutex> type;
+};
+
+template <>
+struct lock_error_type<boost::mutex> {
+ typedef boost::lock_error type;
+};
+
+#if 0
typedef boost::mutex thread_mutex;
template<>
struct timed_interface_tag<boost::mutex> {
- typedef hasnt_timed_interface_tag type;
+ typedef hasnt_timed_interface_tag type;
};
template<>
struct reentrancy_tag<boost::mutex> {
- typedef non_recursive_tag type;
+ typedef non_recursive_tag type;
};
template<>
struct category_tag<boost::mutex> {
- typedef exclusive_lock_tag type;
+ typedef exclusive_lock_tag type;
};
template<>
struct scope_tag<boost::mutex> {
- typedef multi_threaded_tag type;
+ typedef multi_threaded_tag type;
};
template<>
struct lifetime_tag<boost::mutex> {
- typedef process_lifetime_tag type;
+ typedef process_lifetime_tag type;
};
template<>
struct naming_tag<boost::mutex> {
- typedef anonymous_tag type;
+ typedef anonymous_tag type;
};
template <>
struct best_condition<boost::mutex> {
- typedef boost::condition_variable type;
+ typedef boost::condition_variable type;
};
template <>
struct best_condition_any<boost::mutex> {
- typedef boost::condition_variable_any type;
+ typedef boost::condition_variable_any type;
};
+#endif
+
+////////////////////////////////////////////////////
+
+class thread_timed_mutex
+: public lock_traits_base<
+ multi_threaded_tag,
+ exclusive_lock_tag,
+ non_recursive_tag,
+ has_timed_interface_tag,
+ process_lifetime_tag,
+ anonymous_tag,
+ timed_mutex
+>
+{
+
+ //Non-copyable
+ thread_timed_mutex(const thread_mutex &);
+ thread_timed_mutex &operator=(const thread_mutex &);
+
+public:
+
+ typedef boost::condition_variable_any best_condition_type;
+ typedef boost::condition_variable_any best_condition_any_type;
+
+ bool try_lock_until(system_time const & abs_time)
+ {return timed_lock(abs_time);}
+ template<typename TimeDuration>
+ bool try_lock_for(TimeDuration const & relative_time)
+ {return timed_lock(relative_time);}
+};
+
+#if 0
typedef boost::timed_mutex thread_timed_mutex;
template<>
struct timed_interface_tag<boost::timed_mutex> {
- typedef has_timed_interface_tag type;
+ typedef has_timed_interface_tag type;
};
template<>
struct reentrancy_tag<boost::timed_mutex> {
- typedef non_recursive_tag type;
+ typedef non_recursive_tag type;
};
template<>
struct category_tag<boost::timed_mutex> {
- typedef exclusive_lock_tag type;
+ typedef exclusive_lock_tag type;
};
template<>
struct scope_tag<boost::timed_mutex> {
- typedef multi_threaded_tag type;
+ typedef multi_threaded_tag type;
};
template<>
struct lifetime_tag<boost::timed_mutex> {
- typedef process_lifetime_tag type;
+ typedef process_lifetime_tag type;
};
template<>
struct naming_tag<boost::timed_mutex> {
- typedef anonymous_tag type;
+ typedef anonymous_tag type;
};
template <>
struct best_condition<boost::timed_mutex> {
- typedef boost::condition_variable_any type;
+ typedef boost::condition_variable_any type;
};
template <>
struct best_condition_any<boost::timed_mutex> {
- typedef boost::condition_variable_any type;
+ typedef boost::condition_variable_any type;
};
-
+#endif
}
}
Modified: sandbox/synchro/boost/synchro/thread/recursive_mutex.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/thread/recursive_mutex.hpp (original)
+++ sandbox/synchro/boost/synchro/thread/recursive_mutex.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -18,6 +18,30 @@
namespace boost { namespace synchro {
+
+class thread_recursive_mutex
+: public lock_traits_base<
+ multi_threaded_tag,
+ exclusive_lock_tag,
+ recursive_tag,
+ hasnt_timed_interface_tag,
+ process_lifetime_tag,
+ anonymous_tag,
+ recursive_mutex
+>
+{
+
+ //Non-copyable
+ thread_recursive_mutex(const thread_recursive_mutex &);
+ thread_recursive_mutex &operator=(const thread_recursive_mutex &);
+
+public:
+
+ typedef boost::condition_variable_any best_condition_type;
+ typedef boost::condition_variable_any best_condition_any_type;
+ thread_recursive_mutex() {}
+};
+#if 0
typedef boost::recursive_mutex thread_recursive_mutex;
template<>
@@ -58,7 +82,47 @@
struct best_condition_any<boost::recursive_mutex> {
typedef boost::condition_variable_any type;
};
+#endif
+
+
+class thread_recursive_timed_mutex
+: public lock_traits_base<
+ multi_threaded_tag,
+ exclusive_lock_tag,
+ recursive_tag,
+ has_timed_interface_tag,
+ process_lifetime_tag,
+ anonymous_tag,
+ recursive_timed_mutex
+>
+{
+
+ //Non-copyable
+ thread_recursive_timed_mutex(const thread_recursive_timed_mutex &);
+ thread_recursive_timed_mutex &operator=(const thread_recursive_timed_mutex &);
+
+public:
+ thread_recursive_timed_mutex() : lock_traits_base<
+ multi_threaded_tag,
+ exclusive_lock_tag,
+ recursive_tag,
+ has_timed_interface_tag,
+ process_lifetime_tag,
+ anonymous_tag,
+ recursive_timed_mutex
+>(){}
+ typedef boost::condition_variable_any best_condition_type;
+ typedef boost::condition_variable_any best_condition_any_type;
+
+ bool try_lock_until(system_time const & abs_time)
+ {return this->timed_lock(abs_time);}
+ template<typename TimeDuration>
+ bool try_lock_for(TimeDuration const & relative_time)
+ {return timed_lock(relative_time);}
+};
+
+#if 0
typedef boost::recursive_timed_mutex thread_recursive_timed_mutex;
template<>
@@ -97,7 +161,7 @@
typedef boost::condition_variable_any type;
};
-
+#endif
}
}
Modified: sandbox/synchro/boost/synchro/thread/shared_mutex.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/thread/shared_mutex.hpp (original)
+++ sandbox/synchro/boost/synchro/thread/shared_mutex.hpp 2009-02-13 05:03:46 EST (Fri, 13 Feb 2009)
@@ -17,6 +17,42 @@
#include <boost/synchro/thread/lockable_scope_traits.hpp>
namespace boost { namespace synchro {
+
+class thread_shared_mutex
+: public lock_traits_base<
+ multi_threaded_tag,
+ upgradable_lock_tag,
+ non_recursive_tag,
+ has_timed_interface_tag,
+ process_lifetime_tag,
+ anonymous_tag,
+ shared_mutex
+>
+{
+
+ //Non-copyable
+ thread_shared_mutex(const thread_shared_mutex &);
+ thread_shared_mutex &operator=(const thread_shared_mutex &);
+
+public:
+ typedef boost::condition_variable_any best_condition_type;
+ typedef boost::condition_variable_any best_condition_any_type;
+
+ thread_shared_mutex() {}
+
+ bool try_lock_until(system_time const & abs_time)
+ {return this->timed_lock(abs_time);}
+ template<typename TimeDuration>
+ bool try_lock_for(TimeDuration const & relative_time)
+ {return timed_lock(relative_time);}
+
+ bool try_lock_shared_until(system_time const& abs_time)
+ {return timed_lock_shared(abs_time);}
+
+
+};
+
+#if 0
typedef boost::shared_mutex thread_shared_mutex;
@@ -56,7 +92,7 @@
struct best_condition_any<boost::shared_mutex> {
typedef boost::condition_variable_any type;
};
-
+#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