|
Boost-Commit : |
From: pdimov_at_[hidden]
Date: 2008-05-21 16:44:09
Author: pdimov
Date: 2008-05-21 16:44:08 EDT (Wed, 21 May 2008)
New Revision: 45621
URL: http://svn.boost.org/trac/boost/changeset/45621
Log:
Extended boost::thread to 9 arguments, hopefully fixed member function ambiguity.
Added:
trunk/libs/thread/test/test_thread_mf.cpp (contents, props changed)
Text files modified:
trunk/boost/thread/pthread/thread.hpp | 50 +++++++++++++++++++++++++++++++++++++--
trunk/boost/thread/win32/thread.hpp | 50 +++++++++++++++++++++++++++++++++++++--
trunk/libs/thread/test/Jamfile.v2 | 15 ++++++-----
3 files changed, 102 insertions(+), 13 deletions(-)
Modified: trunk/boost/thread/pthread/thread.hpp
==============================================================================
--- trunk/boost/thread/pthread/thread.hpp (original)
+++ trunk/boost/thread/pthread/thread.hpp 2008-05-21 16:44:08 EDT (Wed, 21 May 2008)
@@ -166,19 +166,63 @@
template <class F,class A1>
thread(F f,A1 a1):
- thread_info(make_thread_info(boost::bind<void>(f,a1)))
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1)))
{
start_thread();
}
+
template <class F,class A1,class A2>
thread(F f,A1 a1,A2 a2):
- thread_info(make_thread_info(boost::bind<void>(f,a1,a2)))
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2)))
{
start_thread();
}
+
template <class F,class A1,class A2,class A3>
thread(F f,A1 a1,A2 a2,A3 a3):
- thread_info(make_thread_info(boost::bind<void>(f,a1,a2,a3)))
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3)))
+ {
+ start_thread();
+ }
+
+ template <class F,class A1,class A2,class A3,class A4>
+ thread(F f,A1 a1,A2 a2,A3 a3,A4 a4):
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4)))
+ {
+ start_thread();
+ }
+
+ template <class F,class A1,class A2,class A3,class A4,class A5>
+ thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5):
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5)))
+ {
+ start_thread();
+ }
+
+ template <class F,class A1,class A2,class A3,class A4,class A5,class A6>
+ thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6):
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6)))
+ {
+ start_thread();
+ }
+
+ template <class F,class A1,class A2,class A3,class A4,class A5,class A6,class A7>
+ thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7):
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6,a7)))
+ {
+ start_thread();
+ }
+
+ template <class F,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8>
+ thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8):
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6,a7,a8)))
+ {
+ start_thread();
+ }
+
+ template <class F,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9>
+ thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9):
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6,a7,a8,a9)))
{
start_thread();
}
Modified: trunk/boost/thread/win32/thread.hpp
==============================================================================
--- trunk/boost/thread/win32/thread.hpp (original)
+++ trunk/boost/thread/win32/thread.hpp 2008-05-21 16:44:08 EDT (Wed, 21 May 2008)
@@ -253,19 +253,63 @@
template <class F,class A1>
thread(F f,A1 a1):
- thread_info(make_thread_info(boost::bind<void>(f,a1)))
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1)))
{
start_thread();
}
+
template <class F,class A1,class A2>
thread(F f,A1 a1,A2 a2):
- thread_info(make_thread_info(boost::bind<void>(f,a1,a2)))
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2)))
{
start_thread();
}
+
template <class F,class A1,class A2,class A3>
thread(F f,A1 a1,A2 a2,A3 a3):
- thread_info(make_thread_info(boost::bind<void>(f,a1,a2,a3)))
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3)))
+ {
+ start_thread();
+ }
+
+ template <class F,class A1,class A2,class A3,class A4>
+ thread(F f,A1 a1,A2 a2,A3 a3,A4 a4):
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4)))
+ {
+ start_thread();
+ }
+
+ template <class F,class A1,class A2,class A3,class A4,class A5>
+ thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5):
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5)))
+ {
+ start_thread();
+ }
+
+ template <class F,class A1,class A2,class A3,class A4,class A5,class A6>
+ thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6):
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6)))
+ {
+ start_thread();
+ }
+
+ template <class F,class A1,class A2,class A3,class A4,class A5,class A6,class A7>
+ thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7):
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6,a7)))
+ {
+ start_thread();
+ }
+
+ template <class F,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8>
+ thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8):
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6,a7,a8)))
+ {
+ start_thread();
+ }
+
+ template <class F,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9>
+ thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9):
+ thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6,a7,a8,a9)))
{
start_thread();
}
Modified: trunk/libs/thread/test/Jamfile.v2
==============================================================================
--- trunk/libs/thread/test/Jamfile.v2 (original)
+++ trunk/libs/thread/test/Jamfile.v2 2008-05-21 16:44:08 EDT (Wed, 21 May 2008)
@@ -22,16 +22,16 @@
: requirements <library>/boost/test//boost_unit_test_framework/<link>static
<threading>multi
;
-
+
rule thread-run ( sources )
{
return
- [ run $(sources) ../build//boost_thread ]
- [ run $(sources) ../src/tss_null.cpp ../build//boost_thread/<link>static
- : : : : $(sources[1]:B)_lib ]
- ;
+ [ run $(sources) ../build//boost_thread ]
+ [ run $(sources) ../src/tss_null.cpp ../build//boost_thread/<link>static
+ : : : : $(sources[1]:B)_lib ]
+ ;
}
-
+
{
test-suite "threads"
: [ thread-run test_thread.cpp ]
@@ -39,6 +39,7 @@
[ thread-run test_hardware_concurrency.cpp ]
[ thread-run test_thread_move.cpp ]
[ thread-run test_thread_launching.cpp ]
+ [ thread-run test_thread_mf.cpp ]
[ thread-run test_move_function.cpp ]
[ thread-run test_mutex.cpp ]
[ thread-run test_condition_notify_one.cpp ]
@@ -48,7 +49,7 @@
[ thread-run test_tss.cpp ]
[ thread-run test_once.cpp ]
[ thread-run test_xtime.cpp ]
- [ thread-run test_barrier.cpp ]
+ [ thread-run test_barrier.cpp ]
[ thread-run test_shared_mutex.cpp ]
[ thread-run test_shared_mutex_part_2.cpp ]
[ thread-run test_shared_mutex_timed_locks.cpp ]
Added: trunk/libs/thread/test/test_thread_mf.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/test_thread_mf.cpp 2008-05-21 16:44:08 EDT (Wed, 21 May 2008)
@@ -0,0 +1,136 @@
+//
+// Copyright (C) 2008 Peter Dimov
+//
+// Distributed under the Boost Software License, Version 1.0.
+// See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt
+//
+
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+struct X
+{
+ mutable unsigned int hash;
+
+ X(): hash(0) {}
+
+ int f0() { f1(17); return 0; }
+ int g0() const { g1(17); return 0; }
+
+ int f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; }
+ int g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; }
+
+ int f2(int a1, int a2) { f1(a1); f1(a2); return 0; }
+ int g2(int a1, int a2) const { g1(a1); g1(a2); return 0; }
+
+ int f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; }
+ int g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; }
+
+ int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; }
+ int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; }
+
+ int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; }
+ int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; }
+
+ int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; }
+ int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; }
+
+ int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; }
+ int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; }
+
+ int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; }
+ int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; }
+};
+
+int main()
+{
+ using namespace boost;
+
+ X x;
+
+ // 0
+
+ thread( &X::f0, &x ).join();
+ thread( &X::f0, ref(x) ).join();
+
+ thread( &X::g0, &x ).join();
+ thread( &X::g0, x ).join();
+ thread( &X::g0, ref(x) ).join();
+
+ // 1
+
+ thread( &X::f1, &x, 1 ).join();
+ thread( &X::f1, ref(x), 1 ).join();
+
+ thread( &X::g1, &x, 1 ).join();
+ thread( &X::g1, x, 1 ).join();
+ thread( &X::g1, ref(x), 1 ).join();
+
+ // 2
+
+ thread( &X::f2, &x, 1, 2 ).join();
+ thread( &X::f2, ref(x), 1, 2 ).join();
+
+ thread( &X::g2, &x, 1, 2 ).join();
+ thread( &X::g2, x, 1, 2 ).join();
+ thread( &X::g2, ref(x), 1, 2 ).join();
+
+ // 3
+
+ thread( &X::f3, &x, 1, 2, 3 ).join();
+ thread( &X::f3, ref(x), 1, 2, 3 ).join();
+
+ thread( &X::g3, &x, 1, 2, 3 ).join();
+ thread( &X::g3, x, 1, 2, 3 ).join();
+ thread( &X::g3, ref(x), 1, 2, 3 ).join();
+
+ // 4
+
+ thread( &X::f4, &x, 1, 2, 3, 4 ).join();
+ thread( &X::f4, ref(x), 1, 2, 3, 4 ).join();
+
+ thread( &X::g4, &x, 1, 2, 3, 4 ).join();
+ thread( &X::g4, x, 1, 2, 3, 4 ).join();
+ thread( &X::g4, ref(x), 1, 2, 3, 4 ).join();
+
+ // 5
+
+ thread( &X::f5, &x, 1, 2, 3, 4, 5 ).join();
+ thread( &X::f5, ref(x), 1, 2, 3, 4, 5 ).join();
+
+ thread( &X::g5, &x, 1, 2, 3, 4, 5 ).join();
+ thread( &X::g5, x, 1, 2, 3, 4, 5 ).join();
+ thread( &X::g5, ref(x), 1, 2, 3, 4, 5 ).join();
+
+ // 6
+
+ thread( &X::f6, &x, 1, 2, 3, 4, 5, 6 ).join();
+ thread( &X::f6, ref(x), 1, 2, 3, 4, 5, 6 ).join();
+
+ thread( &X::g6, &x, 1, 2, 3, 4, 5, 6 ).join();
+ thread( &X::g6, x, 1, 2, 3, 4, 5, 6 ).join();
+ thread( &X::g6, ref(x), 1, 2, 3, 4, 5, 6 ).join();
+
+ // 7
+
+ thread( &X::f7, &x, 1, 2, 3, 4, 5, 6, 7).join();
+ thread( &X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7).join();
+
+ thread( &X::g7, &x, 1, 2, 3, 4, 5, 6, 7).join();
+ thread( &X::g7, x, 1, 2, 3, 4, 5, 6, 7).join();
+ thread( &X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7).join();
+
+ // 8
+
+ thread( &X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8 ).join();
+ thread( &X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8 ).join();
+
+ thread( &X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8 ).join();
+ thread( &X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8 ).join();
+ thread( &X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8 ).join();
+
+ BOOST_TEST( x.hash == 23558 );
+
+ return report_errors();
+}
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