|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r76170 - trunk/libs/interprocess/test
From: igaztanaga_at_[hidden]
Date: 2011-12-26 06:10:23
Author: igaztanaga
Date: 2011-12-26 06:10:22 EST (Mon, 26 Dec 2011)
New Revision: 76170
URL: http://svn.boost.org/trac/boost/changeset/76170
Log:
Fixed named condition and unnecessary includes
Text files modified:
trunk/libs/interprocess/test/condition_test_template.hpp | 2 -
trunk/libs/interprocess/test/mutex_test.cpp | 1
trunk/libs/interprocess/test/named_condition_test.cpp | 78 ++++++++++++++++++++++++++++++++++++++-
trunk/libs/interprocess/test/recursive_mutex_test.cpp | 5 +-
4 files changed, 79 insertions(+), 7 deletions(-)
Modified: trunk/libs/interprocess/test/condition_test_template.hpp
==============================================================================
--- trunk/libs/interprocess/test/condition_test_template.hpp (original)
+++ trunk/libs/interprocess/test/condition_test_template.hpp 2011-12-26 06:10:22 EST (Mon, 26 Dec 2011)
@@ -24,12 +24,10 @@
#include <boost/interprocess/detail/workaround.hpp>
#include "boost_interprocess_check.hpp"
#include <boost/thread/detail/config.hpp>
-#include <boost/interprocess/sync/interprocess_condition.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/thread/thread.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/thread/xtime.hpp>
-#include <boost/interprocess/sync/interprocess_mutex.hpp>
#include <iostream>
namespace boost{
Modified: trunk/libs/interprocess/test/mutex_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/mutex_test.cpp (original)
+++ trunk/libs/interprocess/test/mutex_test.cpp 2011-12-26 06:10:22 EST (Mon, 26 Dec 2011)
@@ -9,6 +9,7 @@
//////////////////////////////////////////////////////////////////////////////
#include <boost/interprocess/detail/config_begin.hpp>
+#include <boost/interprocess/detail/workaround.hpp>
#include <boost/interprocess/sync/interprocess_mutex.hpp>
#include "mutex_test_template.hpp"
Modified: trunk/libs/interprocess/test/named_condition_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/named_condition_test.cpp (original)
+++ trunk/libs/interprocess/test/named_condition_test.cpp 2011-12-26 06:10:22 EST (Mon, 26 Dec 2011)
@@ -9,10 +9,9 @@
//////////////////////////////////////////////////////////////////////////////
#include <boost/interprocess/detail/config_begin.hpp>
-#include <boost/interprocess/sync/named_condition.hpp>
+#include <boost/interprocess/detail/workaround.hpp>
#include <boost/interprocess/sync/named_mutex.hpp>
-#include <boost/interprocess/sync/scoped_lock.hpp>
-#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <boost/interprocess/sync/named_condition.hpp>
#include "condition_test_template.hpp"
#include "named_creation_template.hpp"
#include <string>
@@ -56,6 +55,79 @@
~named_condition_test_wrapper()
{ --count; }
+
+ template<class Lock>
+ class lock_wrapper
+ {
+ typedef void (lock_wrapper::*unspecified_bool_type)();
+ public:
+
+ typedef named_mutex mutex_type;
+
+ lock_wrapper(Lock &l)
+ : l_(l)
+ {}
+
+ mutex_type* mutex() const
+ { return l_.mutex(); }
+
+ void lock() { l_.lock(); }
+
+ void unlock() { l_.unlock(); }
+
+ operator unspecified_bool_type() const
+ { return l_ ? &lock_wrapper::lock : 0; }
+
+ private:
+ Lock &l_;
+ };
+/*
+ template<class Lock>
+ class lock_wrapper
+ {
+ public:
+
+ typedef named_mutex mutex_type;
+
+ lock_wrapper(Lock &l)
+ : l_(l)
+ {}
+
+ mutex_type* mutex() const
+ { return l_.mutex(); }
+
+ private:
+ Lock &l_;
+ };
+*/
+ template <typename L>
+ void wait(L& lock)
+ {
+ lock_wrapper<L> newlock(lock);
+ named_condition::wait(newlock);
+ }
+
+ template <typename L, typename Pr>
+ void wait(L& lock, Pr pred)
+ {
+ lock_wrapper<L> newlock(lock);
+ named_condition::wait(newlock, pred);
+ }
+
+ template <typename L>
+ bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time)
+ {
+ lock_wrapper<L> newlock(lock);
+ return named_condition::timed_wait(newlock, abs_time);
+ }
+
+ template <typename L, typename Pr>
+ bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr pred)
+ {
+ lock_wrapper<L> newlock(lock);
+ return named_condition::timed_wait(newlock, abs_time, pred);
+ }
+
static int count;
};
Modified: trunk/libs/interprocess/test/recursive_mutex_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/recursive_mutex_test.cpp (original)
+++ trunk/libs/interprocess/test/recursive_mutex_test.cpp 2011-12-26 06:10:22 EST (Mon, 26 Dec 2011)
@@ -9,9 +9,10 @@
//////////////////////////////////////////////////////////////////////////////
#include <boost/interprocess/detail/config_begin.hpp>
+#include <boost/interprocess/detail/workaround.hpp>
#if defined(BOOST_INTERPROCESS_WINDOWS)
-#include <boost/interprocess/sync/windows/windows_recursive_mutex.hpp>
-#include <boost/interprocess/sync/windows/spin_recursive_mutex.hpp>
+#include <boost/interprocess/sync/windows/recursive_mutex.hpp>
+#include <boost/interprocess/sync/spin/recursive_mutex.hpp>
#endif
#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk