|
Boost-Commit : |
From: mw8329_at_[hidden]
Date: 2007-10-28 12:02:16
Author: martin_wille
Date: 2007-10-28 12:02:15 EDT (Sun, 28 Oct 2007)
New Revision: 40530
URL: http://svn.boost.org/trac/boost/changeset/40530
Log:
-- compensated for changes to Boost.Thread:
o Boost.Thread no longer accepts boost::reference_wrapper instances as callable arguments
o created a new callable_reference_wrapper type that gets used instead of the no longer
accepted type.
Text files modified:
trunk/libs/spirit/test/grammar_mt_tests.cpp | 50 +++++++++++++++++++++++++++------------
trunk/libs/spirit/test/owi_mt_tests.cpp | 24 ++++++++++++++++--
2 files changed, 55 insertions(+), 19 deletions(-)
Modified: trunk/libs/spirit/test/grammar_mt_tests.cpp
==============================================================================
--- trunk/libs/spirit/test/grammar_mt_tests.cpp (original)
+++ trunk/libs/spirit/test/grammar_mt_tests.cpp 2007-10-28 12:02:15 EDT (Sun, 28 Oct 2007)
@@ -152,7 +152,25 @@
simple simple1_p;
};
+////////////////////////////////////////////////////////////////////////////////
+template <typename T>
+class callable_reference_wrapper
+ : public boost::reference_wrapper<T>
+{
+public:
+ explicit callable_reference_wrapper(T& t)
+ : boost::reference_wrapper<T>(t)
+ {}
+ inline void operator()() { this->get().operator()(); }
+};
+template <typename T>
+callable_reference_wrapper<T>
+callable_ref(T &t)
+{
+ return callable_reference_wrapper<T>(t);
+}
+////////////////////////////////////////////////////////////////////////////////
static void
single_local_grammar_object_multiple_threads()
{
@@ -161,10 +179,10 @@
count_guard guard(simple_definition_count);
single_grammar_object_task task1, task2, task3, task4;
- boost::thread t1(boost::ref(task1));
- boost::thread t2(boost::ref(task2));
- boost::thread t3(boost::ref(task3));
- boost::thread t4(boost::ref(task4));
+ boost::thread t1(callable_ref(task1));
+ boost::thread t2(callable_ref(task2));
+ boost::thread t3(callable_ref(task3));
+ boost::thread t4(callable_ref(task4));
t1.join();
t2.join();
@@ -195,10 +213,10 @@
count_guard guard(simple_definition_count);
two_grammar_objects_task task1, task2, task3, task4;
- boost::thread t1(boost::ref(task1));
- boost::thread t2(boost::ref(task2));
- boost::thread t3(boost::ref(task3));
- boost::thread t4(boost::ref(task4));
+ boost::thread t1(callable_ref(task1));
+ boost::thread t2(callable_ref(task2));
+ boost::thread t3(callable_ref(task3));
+ boost::thread t4(callable_ref(task4));
t1.join();
t2.join();
@@ -227,10 +245,10 @@
count_guard guard(simple_definition_count);
single_global_grammar_object_task task1, task2, task3, task4;
- boost::thread t1(boost::ref(task1));
- boost::thread t2(boost::ref(task2));
- boost::thread t3(boost::ref(task3));
- boost::thread t4(boost::ref(task4));
+ boost::thread t1(callable_ref(task1));
+ boost::thread t2(callable_ref(task2));
+ boost::thread t3(callable_ref(task3));
+ boost::thread t4(callable_ref(task4));
t1.join();
t2.join();
@@ -261,10 +279,10 @@
count_guard guard(simple_definition_count);
multiple_global_grammar_objects_task task1, task2, task3, task4;
- boost::thread t1(boost::ref(task1));
- boost::thread t2(boost::ref(task2));
- boost::thread t3(boost::ref(task3));
- boost::thread t4(boost::ref(task4));
+ boost::thread t1(callable_ref(task1));
+ boost::thread t2(callable_ref(task2));
+ boost::thread t3(callable_ref(task3));
+ boost::thread t4(callable_ref(task4));
t1.join();
t2.join();
Modified: trunk/libs/spirit/test/owi_mt_tests.cpp
==============================================================================
--- trunk/libs/spirit/test/owi_mt_tests.cpp (original)
+++ trunk/libs/spirit/test/owi_mt_tests.cpp 2007-10-28 12:02:15 EDT (Sun, 28 Oct 2007)
@@ -109,6 +109,24 @@
unsigned int progress;
};
+template <typename T>
+class callable_reference_wrapper
+ : public boost::reference_wrapper<T>
+{
+public:
+ explicit callable_reference_wrapper(T& t)
+ : boost::reference_wrapper<T>(t)
+ {}
+ inline void operator()() { this->get().operator()(); }
+};
+
+template <typename T>
+callable_reference_wrapper<T>
+callable_ref(T &t)
+{
+ return callable_reference_wrapper<T>(t);
+}
+
test_task<class1> test1;
test_task<class1> test2;
test_task<class1> test3;
@@ -170,9 +188,9 @@
{
{
boost::xtime_get(&start_time, boost::TIME_UTC);
- boost::thread thread1(boost::ref(test1));
- boost::thread thread2(boost::ref(test2));
- boost::thread thread3(boost::ref(test3));
+ boost::thread thread1(callable_ref(test1));
+ boost::thread thread2(callable_ref(test2));
+ boost::thread thread3(callable_ref(test3));
thread1.join();
thread2.join();
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