|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57143 - in sandbox/task: boost/task boost/task/detail libs/task/test
From: oliver.kowalke_at_[hidden]
Date: 2009-10-25 03:04:41
Author: olli
Date: 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
New Revision: 57143
URL: http://svn.boost.org/trac/boost/changeset/57143
Log:
- reinterpet_cast for atomic_interlocked
- boost::uint32_t in tests (required by WIndows)
Text files modified:
sandbox/task/boost/task/detail/atomic_interlocked.hpp | 11 +++++++++--
sandbox/task/boost/task/static_pool.hpp | 2 +-
sandbox/task/libs/task/test/test_bounded_onelock_pool.cpp | 4 ----
sandbox/task/libs/task/test/test_bounded_twolock_pool.cpp | 4 ----
sandbox/task/libs/task/test/test_new_thread.cpp | 4 ----
sandbox/task/libs/task/test/test_own_thread.cpp | 4 ----
sandbox/task/libs/task/test/test_semaphore.cpp | 27 +++++++++++----------------
sandbox/task/libs/task/test/test_spin_auto_reset_event.cpp | 21 +++++++++++----------
sandbox/task/libs/task/test/test_spin_count_down_event.cpp | 33 +++++++++++++++------------------
sandbox/task/libs/task/test/test_spin_manual_reset_event.cpp | 33 +++++++++++++++++----------------
sandbox/task/libs/task/test/test_spin_unique_lock.cpp | 4 ----
sandbox/task/libs/task/test/test_task.cpp | 4 ----
sandbox/task/libs/task/test/test_unbounded_onelock_pool.cpp | 4 ----
sandbox/task/libs/task/test/test_unbounded_twolock_pool.cpp | 4 ----
sandbox/task/libs/task/test/util.ipp | 3 +--
15 files changed, 65 insertions(+), 97 deletions(-)
Modified: sandbox/task/boost/task/detail/atomic_interlocked.hpp
==============================================================================
--- sandbox/task/boost/task/detail/atomic_interlocked.hpp (original)
+++ sandbox/task/boost/task/detail/atomic_interlocked.hpp 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
@@ -23,12 +23,19 @@
inline
void atomic_exchange( uint32_t volatile * object, uint32_t desired)
-{ BOOST_INTERLOCKED_EXCHANGE( reinterpret_cast< long volatile * >( object), desired); }
+{
+ BOOST_INTERLOCKED_EXCHANGE(
+ reinterpret_cast< long volatile * >( object),
+ reinterpret_cast< long >( desired) );
+}
inline
bool atomic_compare_exchange_strong( uint32_t volatile * object, uint32_t * expected, uint32_t desired)
{
- uint32_t prev = BOOST_INTERLOCKED_COMPARE_EXCHANGE( object, desired, * expected);
+ uint32_t prev = BOOST_INTERLOCKED_COMPARE_EXCHANGE(
+ reinterpret_cast< long volatile * >( object),
+ reinterpret_cast< long >( desired),
+ reinterpret_cast< long >( * expected) );
if ( prev != * expected)
{
* expected = prev;
Modified: sandbox/task/boost/task/static_pool.hpp
==============================================================================
--- sandbox/task/boost/task/static_pool.hpp (original)
+++ sandbox/task/boost/task/static_pool.hpp 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
@@ -44,7 +44,7 @@
private:
typedef detail::pool_base< queue_type, ums_type > base_type;
- template< typename T, typename X, typename Z >
+ template< typename T, typename X >
friend class detail::worker_object;
# if defined(BOOST_HAS_PROCESSOR_BINDINGS)
Modified: sandbox/task/libs/task/test/test_bounded_onelock_pool.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_bounded_onelock_pool.cpp (original)
+++ sandbox/task/libs/task/test/test_bounded_onelock_pool.cpp 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
@@ -27,8 +27,6 @@
namespace pt = boost::posix_time;
namespace tsk = boost::task;
-namespace {
-
// check size and move op
void test_case_1()
{
@@ -555,8 +553,6 @@
BOOST_CHECK_EQUAL( buffer.size(), std::size_t( 2) );
}
-}
-
boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
{
boost::unit_test::test_suite * test =
Modified: sandbox/task/libs/task/test/test_bounded_twolock_pool.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_bounded_twolock_pool.cpp (original)
+++ sandbox/task/libs/task/test/test_bounded_twolock_pool.cpp 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
@@ -27,8 +27,6 @@
namespace pt = boost::posix_time;
namespace tsk = boost::task;
-namespace {
-
// check size and move op
void test_case_1()
{
@@ -478,8 +476,6 @@
BOOST_CHECK_EQUAL( buffer.size(), std::size_t( 2) );
}
-}
-
boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
{
boost::unit_test::test_suite * test =
Modified: sandbox/task/libs/task/test/test_new_thread.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_new_thread.cpp (original)
+++ sandbox/task/libs/task/test/test_new_thread.cpp 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
@@ -25,8 +25,6 @@
namespace pt = boost::posix_time;
namespace tsk = boost::task;
-namespace {
-
// check assignment
void test_case_1()
{
@@ -260,8 +258,6 @@
BOOST_CHECK_EQUAL( h2.get(), 55);
}
-}
-
boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
{
boost::unit_test::test_suite * test =
Modified: sandbox/task/libs/task/test/test_own_thread.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_own_thread.cpp (original)
+++ sandbox/task/libs/task/test/test_own_thread.cpp 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
@@ -25,8 +25,6 @@
namespace pt = boost::posix_time;
namespace tsk = boost::task;
-namespace {
-
// check assignment
void test_case_1()
{
@@ -286,8 +284,6 @@
BOOST_CHECK_NO_THROW( h.get() );
}
-}
-
boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
{
boost::unit_test::test_suite * test =
Modified: sandbox/task/libs/task/test/test_semaphore.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_semaphore.cpp (original)
+++ sandbox/task/libs/task/test/test_semaphore.cpp 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
@@ -11,6 +11,7 @@
#include <vector>
#include <boost/bind.hpp>
+#include <boost/cstdint.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/function.hpp>
#include <boost/ref.hpp>
@@ -25,29 +26,25 @@
namespace pt = boost::posix_time;
namespace tsk = boost::task;
-namespace {
-uint32_t wait_fn( uint32_t n, tsk::semaphore & sem)
+boost::uint32_t wait_fn( boost::uint32_t n, tsk::semaphore & sem)
{
sem.wait();
return n;
}
-}
-
-namespace {
// check wait in new thread
void test_case_1()
{
- uint32_t n = 3;
+ boost::uint32_t n = 3;
tsk::semaphore sem( 0);
- tsk::handle< uint32_t > h1(
+ tsk::handle< boost::uint32_t > h1(
tsk::async(
tsk::make_task(
wait_fn,
n, boost::ref( sem) ),
tsk::new_thread() ) );
- tsk::handle< uint32_t > h2(
+ tsk::handle< boost::uint32_t > h2(
tsk::async(
tsk::make_task(
wait_fn,
@@ -95,16 +92,16 @@
tsk::unbounded_onelock_fifo
> pool( tsk::poolsize( 3) );
- uint32_t n = 3;
+ boost::uint32_t n = 3;
tsk::semaphore sem( 0);
- tsk::handle< uint32_t > h1(
+ tsk::handle< boost::uint32_t > h1(
tsk::async(
tsk::make_task(
wait_fn,
n, boost::ref( sem) ),
pool) );
- tsk::handle< uint32_t > h2(
+ tsk::handle< boost::uint32_t > h2(
tsk::async(
tsk::make_task(
wait_fn,
@@ -146,16 +143,16 @@
void test_case_3()
{
- uint32_t n = 3;
+ boost::uint32_t n = 3;
tsk::semaphore sem( 2);
- tsk::handle< uint32_t > h1(
+ tsk::handle< boost::uint32_t > h1(
tsk::async(
tsk::make_task(
wait_fn,
n, boost::ref( sem) ),
tsk::new_thread() ) );
- tsk::handle< uint32_t > h2(
+ tsk::handle< boost::uint32_t > h2(
tsk::async(
tsk::make_task(
wait_fn,
@@ -169,8 +166,6 @@
BOOST_CHECK_EQUAL( h2.get(), n);
}
-}
-
boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
{
boost::unit_test::test_suite * test =
Modified: sandbox/task/libs/task/test/test_spin_auto_reset_event.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_spin_auto_reset_event.cpp (original)
+++ sandbox/task/libs/task/test/test_spin_auto_reset_event.cpp 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
@@ -11,6 +11,7 @@
#include <vector>
#include <boost/bind.hpp>
+#include <boost/cstdint.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/function.hpp>
#include <boost/ref.hpp>
@@ -23,7 +24,7 @@
namespace pt = boost::posix_time;
namespace tsk = boost::task;
-uint32_t wait_fn( uint32_t n, tsk::spin_auto_reset_event & ev)
+boost::uint32_t wait_fn( boost::uint32_t n, tsk::spin_auto_reset_event & ev)
{
ev.wait();
return n;
@@ -32,16 +33,16 @@
// check wait in new thread
void test_case_1()
{
- uint32_t n = 3;
+ boost::uint32_t n = 3;
tsk::spin_auto_reset_event ev;
- tsk::handle< uint32_t > h1(
+ tsk::handle< boost::uint32_t > h1(
tsk::async(
tsk::make_task(
wait_fn,
n, boost::ref( ev) ),
tsk::new_thread() ) );
- tsk::handle< uint32_t > h2(
+ tsk::handle< boost::uint32_t > h2(
tsk::async(
tsk::make_task(
wait_fn,
@@ -89,16 +90,16 @@
tsk::unbounded_onelock_fifo
> pool( tsk::poolsize( 3) );
- uint32_t n = 3;
+ boost::uint32_t n = 3;
tsk::spin_auto_reset_event ev;
- tsk::handle< uint32_t > h1(
+ tsk::handle< boost::uint32_t > h1(
tsk::async(
tsk::make_task(
wait_fn,
n, boost::ref( ev) ),
pool) );
- tsk::handle< uint32_t > h2(
+ tsk::handle< boost::uint32_t > h2(
tsk::async(
tsk::make_task(
wait_fn,
@@ -140,16 +141,16 @@
void test_case_3()
{
- uint32_t n = 3;
+ boost::uint32_t n = 3;
tsk::spin_auto_reset_event ev( true);
- tsk::handle< uint32_t > h1(
+ tsk::handle< boost::uint32_t > h1(
tsk::async(
tsk::make_task(
wait_fn,
n, boost::ref( ev) ),
tsk::new_thread() ) );
- tsk::handle< uint32_t > h2(
+ tsk::handle< boost::uint32_t > h2(
tsk::async(
tsk::make_task(
wait_fn,
Modified: sandbox/task/libs/task/test/test_spin_count_down_event.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_spin_count_down_event.cpp (original)
+++ sandbox/task/libs/task/test/test_spin_count_down_event.cpp 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
@@ -11,6 +11,7 @@
#include <vector>
#include <boost/bind.hpp>
+#include <boost/cstdint.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/function.hpp>
#include <boost/ref.hpp>
@@ -23,9 +24,7 @@
namespace pt = boost::posix_time;
namespace tsk = boost::task;
-namespace {
-
-uint32_t wait_fn( uint32_t n, tsk::spin_count_down_event & ev)
+boost::uint32_t wait_fn( boost::uint32_t n, tsk::spin_count_down_event & ev)
{
ev.wait();
return n;
@@ -34,50 +33,50 @@
// check initial + current
void test_case_1()
{
- uint32_t n = 3;
+ boost::uint32_t n = 3;
tsk::spin_count_down_event ev( n);
BOOST_CHECK_EQUAL( ev.initial(), n);
BOOST_CHECK_EQUAL( ev.current(), n);
ev.set();
BOOST_CHECK_EQUAL( ev.initial(), n);
- BOOST_CHECK_EQUAL( ev.current(), static_cast< uint32_t >( 2) );
+ BOOST_CHECK_EQUAL( ev.current(), static_cast< boost::uint32_t >( 2) );
ev.set();
BOOST_CHECK_EQUAL( ev.initial(), n);
- BOOST_CHECK_EQUAL( ev.current(), static_cast< uint32_t >( 1) );
+ BOOST_CHECK_EQUAL( ev.current(), static_cast< boost::uint32_t >( 1) );
ev.set();
BOOST_CHECK_EQUAL( ev.initial(), n);
- BOOST_CHECK_EQUAL( ev.current(), static_cast< uint32_t >( 0) );
+ BOOST_CHECK_EQUAL( ev.current(), static_cast< boost::uint32_t >( 0) );
ev.set();
BOOST_CHECK_EQUAL( ev.initial(), n);
- BOOST_CHECK_EQUAL( ev.current(), static_cast< uint32_t >( 0) );
+ BOOST_CHECK_EQUAL( ev.current(), static_cast< boost::uint32_t >( 0) );
}
// check wait in new thread
void test_case_2()
{
- uint32_t n = 3;
+ boost::uint32_t n = 3;
tsk::spin_count_down_event ev( n);
BOOST_CHECK_EQUAL( ev.initial(), n);
BOOST_CHECK_EQUAL( ev.current(), n);
- tsk::handle< uint32_t > h(
+ tsk::handle< boost::uint32_t > h(
tsk::async(
tsk::make_task(
wait_fn,
n, boost::ref( ev) ),
tsk::new_thread() ) );
BOOST_CHECK( ! h.is_ready() );
- for ( uint32_t i = 0; i < n; ++i)
+ for ( boost::uint32_t i = 0; i < n; ++i)
{
ev.set();
BOOST_CHECK( ! h.is_ready() );
}
BOOST_CHECK_EQUAL( ev.initial(), n);
- BOOST_CHECK_EQUAL( ev.current(), static_cast< uint32_t >( 0) );
+ BOOST_CHECK_EQUAL( ev.current(), static_cast< boost::uint32_t >( 0) );
BOOST_CHECK_EQUAL( h.get(), n);
}
@@ -88,30 +87,28 @@
tsk::unbounded_onelock_fifo
> pool( tsk::poolsize( 3) );
- uint32_t n = 3;
+ boost::uint32_t n = 3;
tsk::spin_count_down_event ev( n);
BOOST_CHECK_EQUAL( ev.initial(), n);
BOOST_CHECK_EQUAL( ev.current(), n);
- tsk::handle< uint32_t > h(
+ tsk::handle< boost::uint32_t > h(
tsk::async(
tsk::make_task(
wait_fn,
n, boost::ref( ev) ),
pool) );
BOOST_CHECK( ! h.is_ready() );
- for ( uint32_t i = 0; i < n; ++i)
+ for ( boost::uint32_t i = 0; i < n; ++i)
{
ev.set();
BOOST_CHECK( ! h.is_ready() );
}
BOOST_CHECK_EQUAL( ev.initial(), n);
- BOOST_CHECK_EQUAL( ev.current(), static_cast< uint32_t >( 0) );
+ BOOST_CHECK_EQUAL( ev.current(), static_cast< boost::uint32_t >( 0) );
BOOST_CHECK_EQUAL( h.get(), n);
}
-}
-
boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
{
boost::unit_test::test_suite * test =
Modified: sandbox/task/libs/task/test/test_spin_manual_reset_event.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_spin_manual_reset_event.cpp (original)
+++ sandbox/task/libs/task/test/test_spin_manual_reset_event.cpp 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
@@ -11,6 +11,7 @@
#include <vector>
#include <boost/bind.hpp>
+#include <boost/cstdint.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/function.hpp>
#include <boost/ref.hpp>
@@ -23,7 +24,7 @@
namespace pt = boost::posix_time;
namespace tsk = boost::task;
-uint32_t wait_fn( uint32_t n, tsk::spin_manual_reset_event & ev)
+boost::uint32_t wait_fn( boost::uint32_t n, tsk::spin_manual_reset_event & ev)
{
ev.wait();
return n;
@@ -32,16 +33,16 @@
// check wait in new thread
void test_case_1()
{
- uint32_t n = 3;
+ boost::uint32_t n = 3;
tsk::spin_manual_reset_event ev;
- tsk::handle< uint32_t > h1(
+ tsk::handle< boost::uint32_t > h1(
tsk::async(
tsk::make_task(
wait_fn,
n, boost::ref( ev) ),
tsk::new_thread() ) );
- tsk::handle< uint32_t > h2(
+ tsk::handle< boost::uint32_t > h2(
tsk::async(
tsk::make_task(
wait_fn,
@@ -62,13 +63,13 @@
ev.reset();
- tsk::handle< uint32_t > h3(
+ tsk::handle< boost::uint32_t > h3(
tsk::async(
tsk::make_task(
wait_fn,
n, boost::ref( ev) ),
tsk::new_thread() ) );
- tsk::handle< uint32_t > h4(
+ tsk::handle< boost::uint32_t > h4(
tsk::async(
tsk::make_task(
wait_fn,
@@ -95,16 +96,16 @@
tsk::unbounded_onelock_fifo
> pool( tsk::poolsize( 3) );
- uint32_t n = 3;
+ boost::uint32_t n = 3;
tsk::spin_manual_reset_event ev;
- tsk::handle< uint32_t > h1(
+ tsk::handle< boost::uint32_t > h1(
tsk::async(
tsk::make_task(
wait_fn,
n, boost::ref( ev) ),
pool) );
- tsk::handle< uint32_t > h2(
+ tsk::handle< boost::uint32_t > h2(
tsk::async(
tsk::make_task(
wait_fn,
@@ -125,13 +126,13 @@
ev.reset();
- tsk::handle< uint32_t > h3(
+ tsk::handle< boost::uint32_t > h3(
tsk::async(
tsk::make_task(
wait_fn,
n, boost::ref( ev) ),
tsk::new_thread() ) );
- tsk::handle< uint32_t > h4(
+ tsk::handle< boost::uint32_t > h4(
tsk::async(
tsk::make_task(
wait_fn,
@@ -153,16 +154,16 @@
void test_case_3()
{
- uint32_t n = 3;
+ boost::uint32_t n = 3;
tsk::spin_manual_reset_event ev( true);
- tsk::handle< uint32_t > h1(
+ tsk::handle< boost::uint32_t > h1(
tsk::async(
tsk::make_task(
wait_fn,
n, boost::ref( ev) ),
tsk::new_thread() ) );
- tsk::handle< uint32_t > h2(
+ tsk::handle< boost::uint32_t > h2(
tsk::async(
tsk::make_task(
wait_fn,
@@ -177,13 +178,13 @@
ev.reset();
- tsk::handle< uint32_t > h3(
+ tsk::handle< boost::uint32_t > h3(
tsk::async(
tsk::make_task(
wait_fn,
n, boost::ref( ev) ),
tsk::new_thread() ) );
- tsk::handle< uint32_t > h4(
+ tsk::handle< boost::uint32_t > h4(
tsk::async(
tsk::make_task(
wait_fn,
Modified: sandbox/task/libs/task/test/test_spin_unique_lock.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_spin_unique_lock.cpp (original)
+++ sandbox/task/libs/task/test/test_spin_unique_lock.cpp 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
@@ -25,8 +25,6 @@
namespace pt = boost::posix_time;
namespace tsk = boost::task;
-namespace {
-
struct dummy_mutex
{
bool is_locked;
@@ -186,8 +184,6 @@
BOOST_CHECK_EQUAL( lk2.mutex(), & mtx1);
}
-}
-
boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
{
boost::unit_test_framework::test_suite * test =
Modified: sandbox/task/libs/task/test/test_task.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_task.cpp (original)
+++ sandbox/task/libs/task/test/test_task.cpp 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
@@ -25,8 +25,6 @@
namespace pt = boost::posix_time;
namespace tsk = boost::task;
-namespace {
-
void zero_args_fn() {}
int one_arg_fn( int i) { return i; }
int two_args_fn( int i, std::string const& s) { return i; }
@@ -86,8 +84,6 @@
BOOST_CHECK_THROW( t2(), tsk::task_already_executed);
}
-}
-
boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
{
boost::unit_test::test_suite * test =
Modified: sandbox/task/libs/task/test/test_unbounded_onelock_pool.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_unbounded_onelock_pool.cpp (original)
+++ sandbox/task/libs/task/test/test_unbounded_onelock_pool.cpp 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
@@ -27,8 +27,6 @@
namespace pt = boost::posix_time;
namespace tsk = boost::task;
-namespace {
-
// check size and move op
void test_case_1()
{
@@ -479,8 +477,6 @@
BOOST_CHECK_EQUAL( buffer.size(), std::size_t( 2) );
}
-}
-
boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
{
boost::unit_test::test_suite * test =
Modified: sandbox/task/libs/task/test/test_unbounded_twolock_pool.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_unbounded_twolock_pool.cpp (original)
+++ sandbox/task/libs/task/test/test_unbounded_twolock_pool.cpp 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
@@ -27,8 +27,6 @@
namespace pt = boost::posix_time;
namespace tsk = boost::task;
-namespace {
-
// check size and move op
void test_case_1()
{
@@ -410,8 +408,6 @@
BOOST_CHECK_EQUAL( buffer.size(), std::size_t( 2) );
}
-}
-
boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
{
boost::unit_test::test_suite * test =
Modified: sandbox/task/libs/task/test/util.ipp
==============================================================================
--- sandbox/task/libs/task/test/util.ipp (original)
+++ sandbox/task/libs/task/test/util.ipp 2009-10-25 03:04:39 EDT (Sun, 25 Oct 2009)
@@ -23,8 +23,7 @@
namespace pt = boost::posix_time;
-namespace
-{
+namespace {
class execution_monitor
{
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