|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51339 - in sandbox/synchro/boost/synchro: . lockers poly process thread
From: vicente.botet_at_[hidden]
Date: 2009-02-19 18:30:46
Author: viboes
Date: 2009-02-19 18:30:45 EST (Thu, 19 Feb 2009)
New Revision: 51339
URL: http://svn.boost.org/trac/boost/changeset/51339
Log:
V0.0.0 : locker concept tests
Text files modified:
sandbox/synchro/boost/synchro/condition_backdoor.hpp | 16 +++--
sandbox/synchro/boost/synchro/condition_safe.hpp | 16 ++--
sandbox/synchro/boost/synchro/locker_concepts.hpp | 15 +++--
sandbox/synchro/boost/synchro/lockers.hpp | 24 --------
sandbox/synchro/boost/synchro/lockers/condition_locker.hpp | 99 +++++++++++-------------------------
sandbox/synchro/boost/synchro/poly/lock.hpp | 18 +++---
sandbox/synchro/boost/synchro/poly/lock_adapter.hpp | 5 +
sandbox/synchro/boost/synchro/process/locks.hpp | 108 ++++++++++++++++++++++++++++++++-------
sandbox/synchro/boost/synchro/thread/locks.hpp | 101 +++++++++++++++++++++++++++++++-----
sandbox/synchro/boost/synchro/thread/mutex.hpp | 1
sandbox/synchro/boost/synchro/thread/shared_mutex.hpp | 23 ++++++++
11 files changed, 269 insertions(+), 157 deletions(-)
Modified: sandbox/synchro/boost/synchro/condition_backdoor.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/condition_backdoor.hpp (original)
+++ sandbox/synchro/boost/synchro/condition_backdoor.hpp 2009-02-19 18:30:45 EST (Thu, 19 Feb 2009)
@@ -32,18 +32,22 @@
that_.wait(lock);
}
template <typename Locker>
- bool wait_until(Locker& lock, boost::system_time const& abs_time) {
- return that_.wait_until(lock, abs_time);
+ void wait_until(Locker& lock, boost::system_time const& abs_time) {
+ 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);
+ void wait_for(Locker& lock, duration_type const& rel_time) {
+ 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);
+ void wait_when_until(Locker& lock, predicate_type pred, boost::system_time const& abs_time) {
+ that_.wait_when_until(lock, pred, abs_time);
+ }
+ template<typename Locker, typename predicate_type, typename duration_type>
+ void wait_when_for(Locker& lock, predicate_type pred, duration_type const& abs_time) {
+ that_.wait_when_for(lock, pred, abs_time);
}
template <typename Locker>
void notify_one(Locker& lock) {
Modified: sandbox/synchro/boost/synchro/condition_safe.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/condition_safe.hpp (original)
+++ sandbox/synchro/boost/synchro/condition_safe.hpp 2009-02-19 18:30:45 EST (Thu, 19 Feb 2009)
@@ -51,13 +51,13 @@
}
template <typename Locker>
- bool wait_until(Locker& lock, boost::system_time const& abs_time) {
- return cond_.timed_wait(lock);;
+ void wait_until(Locker& lock, boost::system_time const& abs_time) {
+ if (!cond_.timed_wait(lock)) throw timeout_exception();
}
template<typename Locker, typename duration_type>
- bool wait_for(Locker& lock,duration_type const& rel_time) {
- return cond_.timed_wait(lock);
+ void wait_for(Locker& lock,duration_type const& rel_time) {
+ if (!cond_.timed_wait(lock)) throw timeout_exception();
}
// template<typename Locker, typename predicate_type>
@@ -65,12 +65,12 @@
// 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);
+ void wait_when_until(Locker& lock, predicate_type pred, boost::system_time const& abs_time) {
+ if (!cond_.timed_wait(lock, pred, abs_time)) throw timeout_exception();
}
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);
+ void wait_when_for(Locker& lock, predicate_type pred, duration_type const& rel_time) {
+ if (!cond_.timed_wait(lock, pred, rel_time)) throw timeout_exception();
}
private:
Condition cond_;
Modified: sandbox/synchro/boost/synchro/locker_concepts.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/locker_concepts.hpp (original)
+++ sandbox/synchro/boost/synchro/locker_concepts.hpp 2009-02-19 18:30:45 EST (Thu, 19 Feb 2009)
@@ -53,7 +53,7 @@
l2.lock();
if (l2.try_lock()) return;
l2.unlock();
- l2.release();
+ //l2.release();
}
lockable_type mtx_;
system_time t;
@@ -65,11 +65,14 @@
typedef typename lockable_type<Locker>::type lockable_type;
BOOST_CONCEPT_USAGE(TimedLockerConcept) {
- const Locker l1(mtx_);
- Locker l5(mtx_, t);
- Locker l6(mtx_, boost::posix_time::seconds(1));
- Locker l7(t, mtx_);
- Locker l8(boost::posix_time::seconds(1), mtx_);
+ Locker l1(mtx_, t);
+ Locker l2(mtx_, boost::posix_time::seconds(1));
+ Locker l3(mtx_, t, throw_timeout);
+ Locker l4(mtx_, boost::posix_time::seconds(1), throw_timeout);
+ Locker l5(t, mtx_);
+ Locker l6(boost::posix_time::seconds(1), mtx_);
+ Locker l7(nothrow_timeout, t, mtx_);
+ Locker l8(nothrow_timeout, boost::posix_time::seconds(1), mtx_);
l5.lock_until(t);
l5.lock_for(boost::posix_time::seconds(1));
if (l5.try_lock_until(t)) return;
Modified: sandbox/synchro/boost/synchro/lockers.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/lockers.hpp (original)
+++ sandbox/synchro/boost/synchro/lockers.hpp 2009-02-19 18:30:45 EST (Thu, 19 Feb 2009)
@@ -14,31 +14,9 @@
#include <boost/thread/locks.hpp>
#include <boost/synchro/lockable_traits.hpp>
+#include <boost/synchro/locker_options.hpp>
namespace boost { namespace synchro {
-
- struct force_lock_t
- {};
- struct defer_lock_t
- {};
- struct try_to_lock_t
- {};
- struct adopt_lock_t
- {};
- struct throw_timeout_t
- {};
- struct nothrow_timeout_t
- {};
-
-
-
- const force_lock_t force_lock={};
- const defer_lock_t defer_lock={};
- const try_to_lock_t try_to_lock={};
- const adopt_lock_t adopt_lock={};
- const throw_timeout_t throw_timeout={};
- const nothrow_timeout_t nothrow_timeout={};
-
template<typename Mutex, typename ScopeTag=typename scope_tag<Mutex>::type>
class unique_locker;
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-19 18:30:45 EST (Thu, 19 Feb 2009)
@@ -75,11 +75,9 @@
>
class condition_unique_locker
: protected unique_locker<Lockable, ScopeTag>
-// : protected unique_lock_type<Lockable>::type
{
BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
typedef unique_locker<Lockable, ScopeTag> super_type;
- //typedef typename unique_lock_type<Lockable>::type super_type;
public:
typedef Lockable lockable_type;
typedef Condition condition;
@@ -88,16 +86,33 @@
explicit condition_unique_locker(lockable_type& obj)
: super_type(obj) { } /*< locks on construction >*/
+ template<typename TimeDuration>
+ condition_unique_locker(TimeDuration const& target_time, lockable_type& m_)
+ : super_type(target_time, m_)
+ {}
+ condition_unique_locker(system_time const& target_time, lockable_type& m_)
+ : super_type(target_time, m_)
+ {}
+
condition_unique_locker(lockable_type& obj, condition &cond)
: super_type(obj) {
typename condition::backdoor(cond).wait(*static_cast<super_type*>(this)); /*< relock on condition >*/
- //typename condition::backdoor(cond).wait(*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 TimeDuration>
+ condition_unique_locker(TimeDuration const& target_time, lockable_type& obj, condition &cond)
+ : super_type(obj) {
+ typename condition::backdoor(cond).wait_for(target_time, *static_cast<super_type*>(this)); /*< relock on condition >*/
+ }
+ condition_unique_locker(system_time const& target_time, lockable_type& obj, condition &cond)
+ : super_type(obj) {
+ typename condition::backdoor(cond).wait_until(target_time, *static_cast<super_type*>(this)); /*< relock on condition >*/
+ }
+
template <typename Predicate>
condition_unique_locker(lockable_type& obj, condition &cond, Predicate pred)
: super_type(obj) {
@@ -109,6 +124,18 @@
// : super_type(obj) {
// typename condition::backdoor(cond).wait_when(*static_cast<unique_lock<Lockable>*>(this), pred); /*< relock condition when predicate satisfaied>*/
// }
+ template <typename TimeDuration, typename Predicate>
+ condition_unique_locker(TimeDuration const& target_time, lockable_type& obj, condition &cond, Predicate pred)
+ : super_type(obj) {
+ typename condition::backdoor(cond).wait_when_for(*static_cast<super_type*>(this), pred, target_time); /*< relock condition when predicate satisfaied>*/
+ //typename condition::backdoor(cond).wait_when(*this, pred); /*< relock condition when predicate satisfaied>*/
+ }
+ template <typename Predicate>
+ condition_unique_locker(system_time const& target_time, lockable_type& obj, condition &cond, Predicate pred)
+ : super_type(obj) {
+ typename condition::backdoor(cond).wait_when_until(*static_cast<super_type*>(this), pred, target_time); /*< relock condition when predicate satisfaied>*/
+ //typename condition::backdoor(cond).wait_when(*this, pred); /*< relock condition when predicate satisfaied>*/
+ }
~condition_unique_locker() { } /*< unlocks on destruction >*/
@@ -303,72 +330,6 @@
//]
-#if 0
-//[condition_lockable
-template <
- typename Lockable,
- class Condition=condition_safe<typename best_condition<Lockable>::type >
->
-class condition_lockable
- : public Lockable
-{
- BOOST_CONCEPT_ASSERT((LockableConcept<Lockable>));
- typedef Lockable super_type;
-public:
- typedef Lockable lockable_type;
- typedef Condition condition;
-
- condition_lockable()
- : super_type() { }
-
- ~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);
- }
-
- void relock_until(condition & 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 Predicate>
- void relock_when(condition &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, 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);
- }
-
-
-private:
- friend class boost::condition_variable;
- friend class boost::condition_variable_any;
-};
-//]
-#endif
}
}
#endif
Modified: sandbox/synchro/boost/synchro/poly/lock.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/poly/lock.hpp (original)
+++ sandbox/synchro/boost/synchro/poly/lock.hpp 2009-02-19 18:30:45 EST (Thu, 19 Feb 2009)
@@ -26,17 +26,17 @@
struct timed_lock : exclusive_lock {
virtual ~timed_lock()=0;
- bool try_lock_until(boost::system_time const& abs_time)=0;
+ virtual bool try_lock_until(boost::system_time const& abs_time)=0;
template<typename DurationType>
bool try_lock_for(DurationType const& rel_time)
{
- return try_lock_until(get_system_time()+abs_time);
+ return try_lock_until(get_system_time()+rel_time);
}
- bool lock_until(boost::system_time const& abs_time)=0;
+ virtual bool lock_until(boost::system_time const& abs_time)=0;
template<typename DurationType>
bool lock_for(DurationType const& rel_time)
{
- return lock_until(get_system_time()+abs_time);
+ return lock_until(get_system_time()+rel_time);
}
};
@@ -51,13 +51,13 @@
template<typename DurationType>
bool try_lock_shared_for(DurationType const& rel_time)
{
- return try_lock_shared_until(get_system_time()+abs_time);
+ return try_lock_shared_until(get_system_time()+rel_time);
}
- virtual bool lock_shared_until(boost::system_time const& abs_time)=0;
+ virtual void lock_shared_until(boost::system_time const& abs_time)=0;
template<typename DurationType>
- bool lock_shared_for(DurationType const& rel_time)
+ void lock_shared_for(DurationType const& rel_time)
{
- return lock_shared_until(get_system_time()+abs_time);
+ lock_shared_until(get_system_time()+rel_time);
}
virtual void unlock_shared()=0;
};
@@ -77,7 +77,7 @@
virtual void lock_upgrade_until(system_time const&t)=0;
template<typename TimeDuration>
- virtual void lock_upgrade_for(TimeDuration const&t)
+ void lock_upgrade_for(TimeDuration const&t)
{
lock_upgrade_for(t);
}
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-19 18:30:45 EST (Thu, 19 Feb 2009)
@@ -22,6 +22,7 @@
class exclusive_lock_adapter
: public exclusive_lock
{
+public:
typedef Lockable lockable_type;
typedef typename scope_tag<Lockable>::type scope;
typedef typename category_tag<Lockable>::type category;
@@ -63,7 +64,7 @@
bool lock_for(DurationType const& rel_time)
{return lock_for(rel_time);}
private:
- TimeLockable& the_lock() {return *static_cast<SharableLock*>(&this->lock_);}
+ TimeLockable& the_lock() {return *static_cast<TimeLockable*>(&this->lock_);}
};
@@ -123,6 +124,8 @@
void unlock_upgrade_and_lock_shared()
{the_lock().unlock_upgrade_and_lock_shared();}
+ bool try_lock_upgrade()
+ {return the_lock().try_lock_upgrade();}
bool try_lock_upgrade_until(system_time const&t)
{return the_lock().try_lock_upgrade_until(t);}
template<typename TimeDuration>
Modified: sandbox/synchro/boost/synchro/process/locks.hpp
==============================================================================
--- sandbox/synchro/boost/synchro/process/locks.hpp (original)
+++ sandbox/synchro/boost/synchro/process/locks.hpp 2009-02-19 18:30:45 EST (Thu, 19 Feb 2009)
@@ -8,7 +8,7 @@
//
//////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_SYNCHRO_PROCESS_LOCK__HPP
+#ifndef BOOST_SYNCHRO_PROCESS_LOCKS__HPP
#define BOOST_SYNCHRO_PROCESS_LOCKS__HPP
#include <boost/interprocess/sync/scoped_lock.hpp>
@@ -36,13 +36,16 @@
template<typename Mutex>
class unique_locker<Mutex,multi_process_tag>: public unique_lock_type<Mutex>::type {
//typename scope_tag<Mutex>::type == multi_process_tag
- private:
+ //unique_locker(unique_locker const&);
+ //unique_locker& operator= (unique_locker const&);
+
+ public:
typedef Mutex lockable_type;
typedef multi_process_tag scope_tag_type;
typedef typename unique_lock_type<Mutex>::type base_type;
- BOOST_NON_CONST_COPY_CONSTRUCTOR_DELETE(unique_locker) /*< disable copy construction >*/
- BOOST_NON_CONST_COPY_CONSTRUCTOR_DELETE(unique_locker) /*< disable copy asignement >*/
+ BOOST_COPY_CONSTRUCTOR_DELETE(unique_locker) /*< disable copy construction >*/
+ BOOST_COPY_ASSIGNEMENT_DELETE(unique_locker) /*< disable copy asignement >*/
unique_locker(): base_type() {}
@@ -54,30 +57,40 @@
{}
unique_locker(Mutex& m_,try_to_lock_t): base_type(m_, boost::interprocess::try_to_lock)
{}
+
template<typename TimeDuration>
- unique_locker(Mutex& m_,TimeDuration const& target_time): base_type(m_, target_time)
+ unique_locker(Mutex& m_,TimeDuration const& target_time): base_type(m_, boost::get_system_time()+target_time)
{}
unique_locker(Mutex& m_,system_time const& target_time): base_type(m_, target_time)
{}
+
+ template<typename TimeDuration>
+ unique_locker(nothrow_timeout_t, TimeDuration const& target_time, Mutex& m_)
+ : base_type(m_, boost::get_system_time()+target_time)
+ {}
+ unique_locker(nothrow_timeout_t, system_time const& target_time, Mutex& m_)
+ : base_type(m_, target_time)
+ {}
+
template<typename TimeDuration>
unique_locker(Mutex& m_,TimeDuration const& target_time, throw_timeout_t)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::interprocess::defer_lock)
{
lock_for(target_time);
}
unique_locker(Mutex& m_,system_time const& target_time, throw_timeout_t)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::interprocess::defer_lock)
{
lock_until(target_time);
}
template<typename TimeDuration>
unique_locker(TimeDuration const& target_time, Mutex& m_)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::interprocess::defer_lock)
{
lock_for(target_time);
}
unique_locker(system_time const& target_time, Mutex& m_)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::interprocess::defer_lock)
{
lock_until(target_time);
}
@@ -182,7 +195,7 @@
template<typename TimeDuration>
bool try_lock_for(TimeDuration const& relative_time)
{
- return this->timed_lock(relative_time);
+ return this->timed_lock(boost::get_system_time()+relative_time);
}
bool try_lock_until(::boost::system_time const& absolute_time)
@@ -215,7 +228,7 @@
typedef unique_locker<Mutex,multi_process_tag> base_type;
BOOST_NON_CONST_COPY_CONSTRUCTOR_DELETE(try_unique_locker) /*< disable copy construction >*/
- BOOST_NON_CONST_COPY_CONSTRUCTOR_DELETE(try_unique_locker) /*< disable copy asignement >*/
+ BOOST_NON_CONST_COPY_ASSIGNEMENT_DELETE(try_unique_locker) /*< disable copy asignement >*/
try_unique_locker(): base_type() {}
@@ -239,33 +252,33 @@
{}
try_unique_locker(nothrow_timeout_t, system_time const& target_time, Mutex& m_)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::interprocess::defer_lock)
{}
template<typename TimeDuration>
try_unique_locker(nothrow_timeout_t, TimeDuration const& target_time, Mutex& m_)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::interprocess::defer_lock)
{}
try_unique_locker(Mutex& m_,system_time const& target_time, throw_timeout_t)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::interprocess::defer_lock)
{
this->lock_until(target_time);
}
template<typename TimeDuration>
try_unique_locker(Mutex& m_,TimeDuration const& target_time, throw_timeout_t)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::interprocess::defer_lock)
{
this->lock_for(target_time);
}
try_unique_locker(system_time const& target_time, Mutex& m_)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::interprocess::defer_lock)
{
this->lock_until(target_time);
}
template<typename TimeDuration>
try_unique_locker(TimeDuration const& target_time, Mutex& m_)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::interprocess::defer_lock)
{
this->lock_for(target_time);
}
@@ -404,7 +417,7 @@
shared_locker(): base_type() {}
BOOST_NON_CONST_COPY_CONSTRUCTOR_DELETE(shared_locker) /*< disable copy construction >*/
- BOOST_NON_CONST_COPY_CONSTRUCTOR_DELETE(shared_locker) /*< disable copy asignement >*/
+ BOOST_NON_CONST_COPY_ASSIGNEMENT_DELETE(shared_locker) /*< disable copy asignement >*/
explicit shared_locker(Mutex& m_): base_type(m_)
{}
@@ -534,7 +547,7 @@
template<typename Duration>
bool try_lock_for(Duration const& relative_time)
{
- return this->timed_lock(relative_time);
+ return this->timed_lock(boost::get_system_time()+relative_time);
}
template<typename TimeDuration>
@@ -571,6 +584,43 @@
{}
upgrade_locker(Mutex& m_,try_to_lock_t): base_type(m_, boost::interprocess::try_to_lock)
{}
+ upgrade_locker(Mutex& m_,system_time const& target_time)
+ : base_type(m_, target_time)
+ {}
+ template<typename TimeDuration>
+ upgrade_locker(Mutex& m_,TimeDuration const& target_time)
+ : base_type(m_, boost::get_system_time()+target_time)
+ {}
+
+ upgrade_locker(nothrow_timeout_t, system_time const& target_time,Mutex& m_)
+ : base_type(m_, boost::interprocess::defer_lock)
+ {}
+ template<typename TimeDuration>
+ upgrade_locker(nothrow_timeout_t, TimeDuration const& target_time,Mutex& m_)
+ {}
+
+
+ upgrade_locker(Mutex& m_,system_time const& target_time,throw_timeout_t)
+ : base_type(m_, boost::interprocess::defer_lock)
+ {
+ this->lock_until(target_time);
+ }
+ template<typename TimeDuration>
+ upgrade_locker(Mutex& m_,TimeDuration const& target_time,throw_timeout_t)
+ {
+ this->lock_for(target_time);
+ }
+
+ upgrade_locker(system_time const& target_time,Mutex& m_)
+ : base_type(m_, boost::interprocess::defer_lock)
+ {
+ this->lock_until(target_time);
+ }
+ template<typename TimeDuration>
+ upgrade_locker(TimeDuration const& target_time,Mutex& m_)
+ {
+ this->lock_for(target_time);
+ }
upgrade_locker(interprocess::detail::moved_object<upgrade_locker<Mutex, scope_tag_type> > other)
: base_type(interprocess::detail::moved_object<base_type>(other.get()))
@@ -624,6 +674,26 @@
bool owns_lock() const {
return this->owns();
}
+ bool try_lock_until(boost::system_time const& absolute_time)
+ {
+ return this->timed_lock(absolute_time);
+ }
+ template<typename Duration>
+ bool try_lock_for(Duration const& relative_time)
+ {
+ return this->timed_lock(boost::get_system_time()+relative_time);
+ }
+
+ template<typename TimeDuration>
+ void lock_for(TimeDuration const& relative_time)
+ {
+ if(!try_lock_for(relative_time)) throw timeout_exception();
+ }
+
+ void lock_until(::boost::system_time const& absolute_time)
+ {
+ if(!try_lock_until(absolute_time)) throw timeout_exception();
+ }
friend class shared_locker<Mutex, scope_tag_type>;
friend class unique_locker<Mutex, scope_tag_type>;
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-19 18:30:45 EST (Thu, 19 Feb 2009)
@@ -66,22 +66,22 @@
unique_locker(Mutex& m_,TimeDuration const& target_time): base_type(m_, target_time)
{}
- unique_locker(nothrow_timeout_t&, system_time const& target_time, Mutex& m_)
+ unique_locker(nothrow_timeout_t, system_time const& target_time, Mutex& m_)
: base_type(m_, target_time)
{}
template<typename TimeDuration>
- unique_locker(nothrow_timeout_t&, TimeDuration const& target_time, Mutex& m_)
+ unique_locker(nothrow_timeout_t, TimeDuration const& target_time, Mutex& m_)
: base_type(m_, target_time)
{}
unique_locker(Mutex& m_,system_time const& target_time, throw_timeout_t)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::defer_lock)
{
lock_until(target_time);
}
template<typename TimeDuration>
unique_locker(Mutex& m_,TimeDuration const& target_time, throw_timeout_t)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::defer_lock)
{
lock_for(target_time);
}
@@ -89,12 +89,12 @@
template<typename TimeDuration>
unique_locker(TimeDuration const& target_time, Mutex& m_)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::defer_lock)
{
lock_for(target_time);
}
unique_locker(system_time const& target_time, Mutex& m_)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::defer_lock)
{
lock_until(target_time);
}
@@ -243,25 +243,25 @@
try_unique_locker(Mutex& m_,system_time const& target_time, throw_timeout_t)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::defer_lock)
{
this->lock_until(target_time);
}
template<typename TimeDuration>
try_unique_locker(Mutex& m_,TimeDuration const& target_time, throw_timeout_t)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::defer_lock)
{
this->lock_for(target_time);
}
try_unique_locker(system_time const& target_time, Mutex& m_)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::defer_lock)
{
this->lock_until(target_time);
}
template<typename TimeDuration>
try_unique_locker(TimeDuration const& target_time, Mutex& m_)
- : base_type(m_, defer_lock)
+ : base_type(m_, boost::defer_lock)
{
this->lock_for(target_time);
}
@@ -364,12 +364,16 @@
{}
shared_locker(Mutex& m_,system_time const& target_time)
- : base_type(m_, target_time)
- {}
+ : base_type(m_, boost::defer_lock)
+ {
+ try_lock_until(target_time);
+ }
template<typename TimeDuration>
shared_locker(Mutex& m_,TimeDuration const& target_time)
- : base_type(m_, target_time)
- {}
+ : base_type(m_, boost::defer_lock)
+ {
+ try_lock_for(target_time);
+ }
shared_locker(nothrow_timeout_t, system_time const& target_time, Mutex& m_)
: base_type(m_, target_time)
@@ -377,7 +381,7 @@
template<typename TimeDuration>
shared_locker(nothrow_timeout_t, TimeDuration const& target_time, Mutex& m_)
{
- lock_for(target_time);
+ try_lock_for(target_time);
}
shared_locker(Mutex& m_,system_time const& target_time,throw_timeout_t)
@@ -532,6 +536,52 @@
upgrade_locker(Mutex& m_,try_to_lock_t): base_type(m_, boost::try_to_lock)
{}
+ upgrade_locker(Mutex& m_,system_time const& target_time)
+ : base_type(m_, boost::defer_lock)
+ {
+ try_lock_until(target_time);
+ }
+ template<typename TimeDuration>
+ upgrade_locker(Mutex& m_,TimeDuration const& target_time)
+ : base_type(m_, boost::defer_lock)
+ {
+ try_lock_for(target_time);
+ }
+
+ upgrade_locker(nothrow_timeout_t, system_time const& target_time, Mutex& m_)
+ : base_type(m_, boost::defer_lock)
+ {
+ try_lock_until(target_time);
+ }
+ template<typename TimeDuration>
+ upgrade_locker(nothrow_timeout_t, TimeDuration const& target_time, Mutex& m_)
+ {
+ try_lock_for(target_time);
+ }
+
+ upgrade_locker(Mutex& m_,system_time const& target_time,throw_timeout_t)
+ : base_type(m_, boost::defer_lock)
+ {
+ this->lock_until(target_time);
+ }
+ template<typename TimeDuration>
+ upgrade_locker(Mutex& m_,TimeDuration const& target_time,throw_timeout_t)
+ : base_type(m_, boost::defer_lock)
+ {
+ this->lock_for(target_time);
+ }
+
+ template<typename TimeDuration>
+ upgrade_locker(TimeDuration const& target_time, Mutex& m_)
+ {
+ this->lock_for(target_time);
+ }
+ upgrade_locker(system_time const& target_time, Mutex& m_)
+ : base_type(m_, boost::defer_lock)
+ {
+ this->lock_until(target_time);
+ }
+
upgrade_locker(detail::thread_move_t<upgrade_locker<Mutex, scope_tag_type> > other)
: base_type(detail::thread_move_t<base_type>(other.t))
{}
@@ -581,6 +631,27 @@
return l==mutex();
} /*< strict lockers specific function >*/
+ bool try_lock_until(boost::system_time const& absolute_time)
+ {
+ return this->timed_lock(absolute_time);
+ }
+ template<typename Duration>
+ bool try_lock_for(Duration const& relative_time)
+ {
+ return this->timed_lock(boost::get_system_time()+relative_time);
+ }
+
+ template<typename TimeDuration>
+ void lock_for(TimeDuration const& relative_time)
+ {
+ if(!try_lock_for(relative_time)) throw timeout_exception();
+ }
+
+ void lock_until(::boost::system_time const& absolute_time)
+ {
+ if(!try_lock_until(absolute_time)) throw timeout_exception();
+ }
+
friend class shared_locker<Mutex, scope_tag_type>;
friend class unique_locker<Mutex, scope_tag_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-19 18:30:45 EST (Thu, 19 Feb 2009)
@@ -60,7 +60,6 @@
struct upgrade_lock_type<thread_mutex> {
typedef boost::upgrade_lock<boost::mutex> type;
};
-
template <>
struct upgrade_to_unique_locker_type<thread_mutex> {
typedef boost::upgrade_to_unique_lock<boost::mutex> type;
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-19 18:30:45 EST (Thu, 19 Feb 2009)
@@ -19,6 +19,7 @@
#include <boost/synchro/detail/deleted_functions.hpp>
namespace boost { namespace synchro {
+
class thread_shared_mutex
: public lock_traits_base<
@@ -107,6 +108,28 @@
typedef boost::condition_variable_any type;
};
#endif
+
+template <>
+struct unique_lock_type<thread_shared_mutex> {
+ typedef boost::unique_lock<boost::shared_mutex> type;
+};
+template <>
+struct shared_lock_type<thread_shared_mutex> {
+ typedef boost::shared_lock<boost::shared_mutex> type;
+};
+
+
+template <>
+struct upgrade_lock_type<thread_shared_mutex> {
+ typedef boost::upgrade_lock<boost::shared_mutex> type;
+};
+
+
+template <>
+struct upgrade_to_unique_locker_type<thread_shared_mutex> {
+ typedef boost::upgrade_to_unique_lock<boost::shared_mutex> type;
+};
+
}
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk