From e09105de98663ade61cc210d82dd618bfc4884a3 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Sun, 3 Jun 2012 18:11:52 +0000 Subject: [PATCH] Thread: fix TIME_UTC, WINVER, constexpr for tags, and don't use local files [SVN r78802] --- build/Jamfile.v2 | 12 +++---- doc/changes.qbk | 12 ++++++- doc/emulations.qbk | 2 +- doc/mutex_concepts.qbk | 6 ++-- example/starvephil.cpp | 6 ++-- example/tennis.cpp | 4 +-- example/thread.cpp | 2 +- example/xtime.cpp | 2 +- include/boost/thread/detail/config.hpp | 2 +- include/boost/thread/detail/delete.hpp | 11 ++++++ include/boost/thread/future.hpp | 34 +++++++++++++++++++ include/boost/thread/locks.hpp | 6 ++-- include/boost/thread/xtime.hpp | 12 +++---- src/pthread/thread.cpp | 6 ++-- src/pthread/timeconv.inl | 16 ++++----- src/win32/thread.cpp | 5 +++ src/win32/timeconv.inl | 16 ++++----- test/sync/futures/async/async_pass.cpp | 12 ++++--- test/test_condition_notify_all.cpp | 2 +- test/test_condition_notify_one.cpp | 2 +- test/test_condition_timed_wait_times_out.cpp | 2 +- test/test_futures.cpp | 8 ++--- test/test_ml.cpp | 10 +++--- test/test_shared_mutex.cpp | 4 +-- test/test_shared_mutex_part_2.cpp | 4 +-- test/test_shared_mutex_timed_locks.cpp | 4 +-- test/test_shared_mutex_timed_locks_chrono.cpp | 4 +-- test/test_thread_exit.cpp | 8 ++--- test/test_xtime.cpp | 10 +++--- .../this_thread/sleep_for/sleep_for_pass.cpp | 4 ++- .../sleep_until/sleep_until_pass.cpp | 5 ++- test/util.inl | 4 +-- 32 files changed, 152 insertions(+), 85 deletions(-) diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index e7177b2b..18094eb0 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -40,8 +40,8 @@ import path ; project boost/thread : source-location ../src : requirements multi - static:BOOST_THREAD_BUILD_LIB=1 - shared:BOOST_THREAD_BUILD_DLL=1 + static:BOOST_THREAD_STATIC_LINK=1 + shared:BOOST_THREAD_DYN_LINK=1 -@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag @$(__name__).tag gcc:-Wno-long-long @@ -92,8 +92,8 @@ project boost/thread # : default-build multi : usage-requirements # pass these requirement to dependents (i.e. users) - static:BOOST_THREAD_BUILD_LIB=1 - shared:BOOST_THREAD_BUILD_DLL=1 + static:BOOST_THREAD_STATIC_LINK=1 + shared:BOOST_THREAD_DYN_LINK=1 BOOST_SYSTEM_NO_DEPRECATED /boost/system//boost_system ; @@ -263,7 +263,7 @@ lib boost_thread : thread_sources future.cpp : @requirements : - : shared:BOOST_THREAD_USE_DLL=1 - static:BOOST_THREAD_USE_LIB=1 + : #shared:BOOST_THREAD_USE_DLL=1 + #static:BOOST_THREAD_USE_LIB=1 @usage-requirements ; diff --git a/doc/changes.qbk b/doc/changes.qbk index 51ec4dbe..ffbad443 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -20,25 +20,34 @@ New Features: * [@http://svn.boost.org/trac/boost/ticket/6195 #6195] c++11 compliance: Provide the standard time related interface using Boost.Chrono. * [@http://svn.boost.org/trac/boost/ticket/6217 #6217] Enhance Boost.Thread shared mutex interface following Howard Hinnant proposal. * [@http://svn.boost.org/trac/boost/ticket/6224 #6224] c++11 compliance: Add the use of standard noexcept on compilers supporting them. +* [@http://svn.boost.org/trac/boost/ticket/6225 #6225] Add the use of standard =delete defaulted operations on compilers supporting them. * [@http://svn.boost.org/trac/boost/ticket/6226 #6226] c++11 compliance: Add explicit bool conversion from locks. * [@http://svn.boost.org/trac/boost/ticket/6228 #6228] Add promise constructor with allocator following the standard c++11. +* [@http://svn.boost.org/trac/boost/ticket/6229 #6229] Rename the unique_future to future following the c++11. * [@http://svn.boost.org/trac/boost/ticket/6230 #6230] c++11 compliance: Follows the exception reporting mechanism as defined in the c++11. +* [@http://svn.boost.org/trac/boost/ticket/6231 #6231] Add BasicLockable requirements in the documentation to follow c++11. * [@http://svn.boost.org/trac/boost/ticket/6266 #6266] Breaking change: thread destructor should call terminate if joinable. * [@http://svn.boost.org/trac/boost/ticket/6269 #6269] Breaking change: thread move assignment should call terminate if joinable. * [@http://svn.boost.org/trac/boost/ticket/6272 #6272] c++11 compliance: Add thread::id hash specialization. * [@http://svn.boost.org/trac/boost/ticket/6273 #6273] c++11 compliance: Add cv_status enum class and use it on the conditions wait functions. -* [@http://svn.boost.org/trac/boost/ticket/6231 #6231] Add BasicLockable requirements in the documentation to follow c++11. * [@http://svn.boost.org/trac/boost/ticket/6342 #6342] c++11 compliance: Adapt the one_flag to the c++11 interface. * [@http://svn.boost.org/trac/boost/ticket/6671 #6671] upgrade_lock: missing mutex and release functions. * [@http://svn.boost.org/trac/boost/ticket/6672 #6672] upgrade_lock:: missing constructors from time related types. * [@http://svn.boost.org/trac/boost/ticket/6675 #6675] upgrade_lock:: missing non-member swap. +* [@http://svn.boost.org/trac/boost/ticket/6676 #6676] lock conversion should be explicit. * Added missing packaged_task::result_type and packaged_task:: constructor with allocator. * Added packaged_task::reset() + Fixed Bugs: +* [@http://svn.boost.org/trac/boost/ticket/2380 #2380] boost::move from lvalue does not work with gcc. +* [@http://svn.boost.org/trac/boost/ticket/2430 #2430] shared_mutex for win32 doesn't have timed_lock_upgrade. * [@http://svn.boost.org/trac/boost/ticket/2575 #2575] Bug- Boost 1.36.0 on Itanium platform. +* [@http://svn.boost.org/trac/boost/ticket/3160 #3160] Duplicate tutorial code in boost::thread. * [@http://svn.boost.org/trac/boost/ticket/4345 #4345] thread::id and joining problem with cascade of threads. +* [@http://svn.boost.org/trac/boost/ticket/4521 #4521] Error using boost::move on packaged_task (MSVC 10). +* [@http://svn.boost.org/trac/boost/ticket/4711 #4711] Must use implementation details to return move-only types. * [@http://svn.boost.org/trac/boost/ticket/4921 #4921] BOOST_THREAD_USE_DLL and BOOST_THREAD_USE_LIB are crucial and need to be documented. * [@http://svn.boost.org/trac/boost/ticket/5013 #5013] documentation: boost::thread: pthreas_exit causes terminate(). * [@http://svn.boost.org/trac/boost/ticket/5173 #5173] boost::this_thread::get_id is very slow. @@ -47,6 +56,7 @@ Fixed Bugs: * [@http://svn.boost.org/trac/boost/ticket/5990 #5990] shared_future::get() has wrong return type. * [@http://svn.boost.org/trac/boost/ticket/6174 #6174] packaged_task doesn't correctly handle moving results. * [@http://svn.boost.org/trac/boost/ticket/6222 #6222] Compile error with SunStudio: unique_future move. +* [@http://svn.boost.org/trac/boost/ticket/6354 #6354] PGI: Compiler threading support is not turned on. * [@http://svn.boost.org/trac/boost/ticket/6673 #6673] shared_lock: move assign doesn't works with c++11. * [@http://svn.boost.org/trac/boost/ticket/6674 #6674] shared_mutex: try_lock_upgrade_until doesn't works. * Fix issue signaled on the ML with task_object(task_object const&) in presence of task_object(task_object &&) diff --git a/doc/emulations.qbk b/doc/emulations.qbk index 383ea52c..d507b392 100644 --- a/doc/emulations.qbk +++ b/doc/emulations.qbk @@ -340,7 +340,7 @@ Instead of use - switch (BOOST_SCOPED_ENUM_NATIVE(future_errc)(ev)) + switch (boost::native_value(ev)) { case future_errc::broken_promise: diff --git a/doc/mutex_concepts.qbk b/doc/mutex_concepts.qbk index dd8c5b94..aa33179b 100644 --- a/doc/mutex_concepts.qbk +++ b/doc/mutex_concepts.qbk @@ -795,9 +795,9 @@ blocking.]] struct defer_lock_t {}; struct try_to_lock_t {}; struct adopt_lock_t {}; - const defer_lock_t defer_lock; - const try_to_lock_t try_to_lock; - const adopt_lock_t adopt_lock; + constexpr defer_lock_t defer_lock; + constexpr try_to_lock_t try_to_lock; + constexpr adopt_lock_t adopt_lock; template class lock_guard diff --git a/example/starvephil.cpp b/example/starvephil.cpp index 034ad0b7..85e8c892 100644 --- a/example/starvephil.cpp +++ b/example/starvephil.cpp @@ -50,7 +50,7 @@ public: << "very hot ..." << std::endl; } boost::xtime xt; - boost::xtime_get(&xt, boost::TIME_UTC); + boost::xtime_get(&xt, boost::TIME_UTC_); xt.sec += 3; boost::thread::sleep(xt); m_chickens += value; @@ -85,7 +85,7 @@ void chef() std::cout << "(" << clock() << ") Chef: cooking ..." << std::endl; } boost::xtime xt; - boost::xtime_get(&xt, boost::TIME_UTC); + boost::xtime_get(&xt, boost::TIME_UTC_); xt.sec += 2; boost::thread::sleep(xt); { @@ -111,7 +111,7 @@ struct phil if (m_id > 0) { boost::xtime xt; - boost::xtime_get(&xt, boost::TIME_UTC); + boost::xtime_get(&xt, boost::TIME_UTC_); xt.sec += 3; boost::thread::sleep(xt); } diff --git a/example/tennis.cpp b/example/tennis.cpp index 798f55e5..1a45eb1f 100644 --- a/example/tennis.cpp +++ b/example/tennis.cpp @@ -1,7 +1,7 @@ // Copyright (C) 2001-2003 // William E. Kempf // -// Distributed under the Boost Software License, Version 1.0. (See accompanying +// 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 @@ -104,7 +104,7 @@ int main(int argc, char* argv[]) boost::thread thrdb(thread_adapter(&player, (void*)PLAYER_B)); boost::xtime xt; - boost::xtime_get(&xt, boost::TIME_UTC); + boost::xtime_get(&xt, boost::TIME_UTC_); xt.sec += 1; boost::thread::sleep(xt); { diff --git a/example/thread.cpp b/example/thread.cpp index 6acbd6da..ebd77977 100644 --- a/example/thread.cpp +++ b/example/thread.cpp @@ -14,7 +14,7 @@ struct thread_alarm void operator()() { boost::xtime xt; - boost::xtime_get(&xt, boost::TIME_UTC); + boost::xtime_get(&xt, boost::TIME_UTC_); xt.sec += m_secs; boost::thread::sleep(xt); diff --git a/example/xtime.cpp b/example/xtime.cpp index a9f10c35..91646e6b 100644 --- a/example/xtime.cpp +++ b/example/xtime.cpp @@ -10,7 +10,7 @@ int main() { boost::xtime xt; - boost::xtime_get(&xt, boost::TIME_UTC); + boost::xtime_get(&xt, boost::TIME_UTC_); xt.sec += 1; boost::thread::sleep(xt); // Sleep for 1 second } diff --git a/include/boost/thread/detail/config.hpp b/include/boost/thread/detail/config.hpp index 3a08ddf5..d9270df8 100644 --- a/include/boost/thread/detail/config.hpp +++ b/include/boost/thread/detail/config.hpp @@ -131,7 +131,7 @@ # pragma warn -8066 // Unreachable code #endif -#include "platform.hpp" +#include // provided for backwards compatibility, since this // macro was used for several releases by mistake. diff --git a/include/boost/thread/detail/delete.hpp b/include/boost/thread/detail/delete.hpp index 63759e8b..9e56d442 100644 --- a/include/boost/thread/detail/delete.hpp +++ b/include/boost/thread/detail/delete.hpp @@ -8,6 +8,13 @@ #include +/** + * BOOST_THREAD_DELETE_COPY_CTOR deletes the copy constructor when the compiler supports it or + * makes it private. + * + * BOOST_THREAD_DELETE_COPY_ASSIGN deletes the copy assignment when the compiler supports it or + * makes it private. + */ #ifndef BOOST_NO_DELETED_FUNCTIONS #define BOOST_THREAD_DELETE_COPY_CTOR(CLASS) \ CLASS(CLASS const&) = delete; \ @@ -27,6 +34,10 @@ public: #endif // BOOST_NO_DELETED_FUNCTIONS +/** + * BOOST_THREAD_NO_COPYABLE deletes the copy constructor and assignment when the compiler supports it or + * makes them private. + */ #define BOOST_THREAD_NO_COPYABLE(CLASS) \ BOOST_THREAD_DELETE_COPY_CTOR(CLASS) \ BOOST_THREAD_DELETE_COPY_ASSIGN(CLASS) diff --git a/include/boost/thread/future.hpp b/include/boost/thread/future.hpp index c238a574..91a585fa 100644 --- a/include/boost/thread/future.hpp +++ b/include/boost/thread/future.hpp @@ -43,6 +43,9 @@ #include #endif +#include +//#include + #if defined BOOST_THREAD_PROVIDES_FUTURE #define BOOST_THREAD_FUTURE future #else @@ -1655,6 +1658,37 @@ namespace boost BOOST_THREAD_DCL_MOVABLE_BEG(T) packaged_task BOOST_THREAD_DCL_MOVABLE_END +// template +// BOOST_THREAD_FUTURE::type> +// async(launch policy, F f) +// { +// typedef typename boost::result_of::type R; +// typedef BOOST_THREAD_FUTURE future; +// if (int(policy) & int(launch::async)) +// { +// packaged_task pt( f ); +// +// BOOST_THREAD_FUTURE ret = pt.get_future(); +// boost::thread( boost::move(pt) ).detach(); +// return ::boost::move(ret); +// } +// else if (int(policy) & int(launch::deferred)) +// { +// packaged_task pt( f ); +// +// BOOST_THREAD_FUTURE ret = pt.get_future(); +// return ::boost::move(ret); +// } +// } +// +// template +// BOOST_THREAD_FUTURE::type> +// async(F f) +// { +// return async(launch::any, f); +// } + + } diff --git a/include/boost/thread/locks.hpp b/include/boost/thread/locks.hpp index 30bd8400..5111d33e 100644 --- a/include/boost/thread/locks.hpp +++ b/include/boost/thread/locks.hpp @@ -170,9 +170,9 @@ namespace boost struct adopt_lock_t {}; - const defer_lock_t defer_lock={}; - const try_to_lock_t try_to_lock={}; - const adopt_lock_t adopt_lock={}; + BOOST_CONSTEXPR_OR_CONST defer_lock_t defer_lock={}; + BOOST_CONSTEXPR_OR_CONST try_to_lock_t try_to_lock={}; + BOOST_CONSTEXPR_OR_CONST adopt_lock_t adopt_lock={}; template class shared_lock; diff --git a/include/boost/thread/xtime.hpp b/include/boost/thread/xtime.hpp index 7cc6272d..1ca996fa 100644 --- a/include/boost/thread/xtime.hpp +++ b/include/boost/thread/xtime.hpp @@ -2,7 +2,7 @@ // William E. Kempf // Copyright (C) 2007-8 Anthony Williams // -// Distributed under the Boost Software License, Version 1.0. (See accompanying +// 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) #ifndef BOOST_XTIME_WEK070601_HPP @@ -20,7 +20,7 @@ namespace boost { enum xtime_clock_types { - TIME_UTC=1 + TIME_UTC_=1 // TIME_TAI, // TIME_MONOTONIC, // TIME_PROCESS, @@ -53,14 +53,14 @@ struct xtime boost::posix_time::microseconds((nsec+500)/1000); #endif } - + }; inline xtime get_xtime(boost::system_time const& abs_time) { xtime res; boost::posix_time::time_duration const time_since_epoch=abs_time-boost::posix_time::from_time_t(0); - + res.sec=static_cast(time_since_epoch.total_seconds()); res.nsec=static_cast(time_since_epoch.fractional_seconds()*(1000000000/time_since_epoch.ticks_per_second())); return res; @@ -68,7 +68,7 @@ inline xtime get_xtime(boost::system_time const& abs_time) inline int xtime_get(struct xtime* xtp, int clock_type) { - if (clock_type == TIME_UTC) + if (clock_type == TIME_UTC_) { *xtp=get_xtime(get_system_time()); return clock_type; @@ -81,7 +81,7 @@ inline int xtime_cmp(const xtime& xt1, const xtime& xt2) { if (xt1.sec == xt2.sec) return (int)(xt1.nsec - xt2.nsec); - else + else return (xt1.sec > xt2.sec) ? 1 : -1; } diff --git a/src/pthread/thread.cpp b/src/pthread/thread.cpp index 7d3f0dd3..0be3cdc9 100644 --- a/src/pthread/thread.cpp +++ b/src/pthread/thread.cpp @@ -24,7 +24,7 @@ #include #endif -#include "timeconv.inl" +#include namespace boost { @@ -416,7 +416,7 @@ namespace boost cond.timed_wait(lock, xt); # endif xtime cur; - xtime_get(&cur, TIME_UTC); + xtime_get(&cur, TIME_UTC_); if (xtime_cmp(xt, cur) <= 0) return; } @@ -458,7 +458,7 @@ namespace boost BOOST_VERIFY(!pthread_yield()); # else xtime xt; - xtime_get(&xt, TIME_UTC); + xtime_get(&xt, TIME_UTC_); sleep(xt); # endif } diff --git a/src/pthread/timeconv.inl b/src/pthread/timeconv.inl index 1c0a0cdc..cab7c55a 100644 --- a/src/pthread/timeconv.inl +++ b/src/pthread/timeconv.inl @@ -20,8 +20,8 @@ const int NANOSECONDS_PER_MICROSECOND = 1000; inline void to_time(int milliseconds, boost::xtime& xt) { int res = 0; - res = boost::xtime_get(&xt, boost::TIME_UTC); - BOOST_ASSERT(res == boost::TIME_UTC); (void)res; + res = boost::xtime_get(&xt, boost::TIME_UTC_); + BOOST_ASSERT(res == boost::TIME_UTC_); (void)res; xt.sec += (milliseconds / MILLISECONDS_PER_SECOND); xt.nsec += ((milliseconds % MILLISECONDS_PER_SECOND) * @@ -56,8 +56,8 @@ inline void to_timespec_duration(const boost::xtime& xt, timespec& ts) { boost::xtime cur; int res = 0; - res = boost::xtime_get(&cur, boost::TIME_UTC); - BOOST_ASSERT(res == boost::TIME_UTC); (void)res; + res = boost::xtime_get(&cur, boost::TIME_UTC_); + BOOST_ASSERT(res == boost::TIME_UTC_); (void)res; if (boost::xtime_cmp(xt, cur) <= 0) { @@ -87,8 +87,8 @@ inline void to_duration(boost::xtime xt, int& milliseconds) { boost::xtime cur; int res = 0; - res = boost::xtime_get(&cur, boost::TIME_UTC); - BOOST_ASSERT(res == boost::TIME_UTC); (void)res; + res = boost::xtime_get(&cur, boost::TIME_UTC_); + BOOST_ASSERT(res == boost::TIME_UTC_); (void)res; if (boost::xtime_cmp(xt, cur) <= 0) milliseconds = 0; @@ -109,8 +109,8 @@ inline void to_microduration(boost::xtime xt, int& microseconds) { boost::xtime cur; int res = 0; - res = boost::xtime_get(&cur, boost::TIME_UTC); - BOOST_ASSERT(res == boost::TIME_UTC); (void)res; + res = boost::xtime_get(&cur, boost::TIME_UTC_); + BOOST_ASSERT(res == boost::TIME_UTC_); (void)res; if (boost::xtime_cmp(xt, cur) <= 0) microseconds = 0; diff --git a/src/win32/thread.cpp b/src/win32/thread.cpp index 2cb35a26..5497fe3f 100644 --- a/src/win32/thread.cpp +++ b/src/win32/thread.cpp @@ -4,8 +4,13 @@ // (C) Copyright 2007 Anthony Williams // (C) Copyright 2007 David Deakins +#ifndef _WIN32_WINNT #define _WIN32_WINNT 0x400 +#endif + +#ifndef WINVER #define WINVER 0x400 +#endif #include #include diff --git a/src/win32/timeconv.inl b/src/win32/timeconv.inl index 5ec3b179..c6467832 100644 --- a/src/win32/timeconv.inl +++ b/src/win32/timeconv.inl @@ -17,8 +17,8 @@ const int NANOSECONDS_PER_MICROSECOND = 1000; inline void to_time(int milliseconds, boost::xtime& xt) { int res = 0; - res = boost::xtime_get(&xt, boost::TIME_UTC); - assert(res == boost::TIME_UTC); + res = boost::xtime_get(&xt, boost::TIME_UTC_); + assert(res == boost::TIME_UTC_); xt.sec += (milliseconds / MILLISECONDS_PER_SECOND); xt.nsec += ((milliseconds % MILLISECONDS_PER_SECOND) * @@ -54,8 +54,8 @@ inline void to_timespec_duration(const boost::xtime& xt, timespec& ts) { boost::xtime cur; int res = 0; - res = boost::xtime_get(&cur, boost::TIME_UTC); - assert(res == boost::TIME_UTC); + res = boost::xtime_get(&cur, boost::TIME_UTC_); + assert(res == boost::TIME_UTC_); if (boost::xtime_cmp(xt, cur) <= 0) { @@ -85,8 +85,8 @@ inline void to_duration(boost::xtime xt, int& milliseconds) { boost::xtime cur; int res = 0; - res = boost::xtime_get(&cur, boost::TIME_UTC); - assert(res == boost::TIME_UTC); + res = boost::xtime_get(&cur, boost::TIME_UTC_); + assert(res == boost::TIME_UTC_); if (boost::xtime_cmp(xt, cur) <= 0) milliseconds = 0; @@ -107,8 +107,8 @@ inline void to_microduration(boost::xtime xt, int& microseconds) { boost::xtime cur; int res = 0; - res = boost::xtime_get(&cur, boost::TIME_UTC); - assert(res == boost::TIME_UTC); + res = boost::xtime_get(&cur, boost::TIME_UTC_); + assert(res == boost::TIME_UTC_); if (boost::xtime_cmp(xt, cur) <= 0) microseconds = 0; diff --git a/test/sync/futures/async/async_pass.cpp b/test/sync/futures/async/async_pass.cpp index b13c844e..a41aea56 100644 --- a/test/sync/futures/async/async_pass.cpp +++ b/test/sync/futures/async/async_pass.cpp @@ -24,6 +24,8 @@ #include +#include +#include #include #include @@ -49,13 +51,13 @@ void f2() boost::this_thread::sleep_for(ms(200)); } -boost::unique_ptr f3(int i) +boost::interprocess::unique_ptr f3(int i) { boost::this_thread::sleep_for(ms(200)); - return boost::unique_ptr(new int(i)); + return boost::interprocess::unique_ptr(new int(i)); } -boost::unique_ptr f4(boost::unique_ptr&& p) +boost::interprocess::unique_ptr f4(boost::interprocess::unique_ptr&& p) { boost::this_thread::sleep_for(ms(200)); return boost::move(p); @@ -163,7 +165,7 @@ int main() } { - boost::future> f = boost::async(f3, 3); + boost::future> f = boost::async(f3, 3); boost::this_thread::sleep_for(ms(300)); Clock::time_point t0 = Clock::now(); BOOST_TEST(*f.get() == 3); @@ -172,7 +174,7 @@ int main() } { - boost::future> f = boost::async(f4, boost::unique_ptr(new int(3))); + boost::future> f = boost::async(f4, boost::interprocess::unique_ptr(new int(3))); boost::this_thread::sleep_for(ms(300)); Clock::time_point t0 = Clock::now(); BOOST_TEST(*f.get() == 3); diff --git a/test/test_condition_notify_all.cpp b/test/test_condition_notify_all.cpp index 556ab665..aaae066a 100644 --- a/test/test_condition_notify_all.cpp +++ b/test/test_condition_notify_all.cpp @@ -10,7 +10,7 @@ #include #include -#include "condition_test_common.hpp" +#include unsigned const number_of_test_threads=5; diff --git a/test/test_condition_notify_one.cpp b/test/test_condition_notify_one.cpp index 1ec253dc..fbee012c 100644 --- a/test/test_condition_notify_one.cpp +++ b/test/test_condition_notify_one.cpp @@ -10,7 +10,7 @@ #include #include -#include "condition_test_common.hpp" +#include void do_test_condition_notify_one_wakes_from_wait() { diff --git a/test/test_condition_timed_wait_times_out.cpp b/test/test_condition_timed_wait_times_out.cpp index 2fc7aa70..03391410 100644 --- a/test/test_condition_timed_wait_times_out.cpp +++ b/test/test_condition_timed_wait_times_out.cpp @@ -9,7 +9,7 @@ #include #include -#include "util.inl" +#include bool fake_predicate() { diff --git a/test/test_futures.cpp b/test/test_futures.cpp index 21008ce2..68a03f53 100644 --- a/test/test_futures.cpp +++ b/test/test_futures.cpp @@ -4,10 +4,10 @@ // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include "boost/thread/thread.hpp" -#include "boost/thread/mutex.hpp" -#include "boost/thread/condition.hpp" -#include "boost/thread/future.hpp" +#include +#include +#include +#include #include #include #include diff --git a/test/test_ml.cpp b/test/test_ml.cpp index 51dabc94..08707c23 100755 --- a/test/test_ml.cpp +++ b/test/test_ml.cpp @@ -2,8 +2,8 @@ #ifndef BOOST_NO_RVALUE_REFERENCES #include -#include "boost/thread/future.hpp" -#include "boost/utility/result_of.hpp" +#include +#include #include struct async_func { @@ -116,9 +116,9 @@ int main() /* * - * #include "boost/test/unit_test.hpp" -#include "boost/thread/future.hpp" -#include "boost/utility/result_of.hpp" + * #include +#include +#include #include struct async_func { diff --git a/test/test_shared_mutex.cpp b/test/test_shared_mutex.cpp index 0ff3ad17..00c64274 100644 --- a/test/test_shared_mutex.cpp +++ b/test/test_shared_mutex.cpp @@ -6,8 +6,8 @@ #include #include #include -#include "util.inl" -#include "shared_mutex_locking_thread.hpp" +#include +#include #define CHECK_LOCKED_VALUE_EQUAL(mutex_name,value,expected_value) \ { \ diff --git a/test/test_shared_mutex_part_2.cpp b/test/test_shared_mutex_part_2.cpp index 89b12650..ee8b4015 100644 --- a/test/test_shared_mutex_part_2.cpp +++ b/test/test_shared_mutex_part_2.cpp @@ -6,8 +6,8 @@ #include #include #include -#include "util.inl" -#include "shared_mutex_locking_thread.hpp" +#include +#include #define CHECK_LOCKED_VALUE_EQUAL(mutex_name,value,expected_value) \ { \ diff --git a/test/test_shared_mutex_timed_locks.cpp b/test/test_shared_mutex_timed_locks.cpp index bf3a4ce6..f341e0a0 100644 --- a/test/test_shared_mutex_timed_locks.cpp +++ b/test/test_shared_mutex_timed_locks.cpp @@ -6,8 +6,8 @@ #include #include #include -#include "util.inl" -#include "shared_mutex_locking_thread.hpp" +#include +#include #define CHECK_LOCKED_VALUE_EQUAL(mutex_name,value,expected_value) \ { \ diff --git a/test/test_shared_mutex_timed_locks_chrono.cpp b/test/test_shared_mutex_timed_locks_chrono.cpp index 654d06e9..847cd0be 100644 --- a/test/test_shared_mutex_timed_locks_chrono.cpp +++ b/test/test_shared_mutex_timed_locks_chrono.cpp @@ -6,8 +6,8 @@ #include #include #include -#include "util.inl" -#include "shared_mutex_locking_thread.hpp" +#include +#include #if defined BOOST_THREAD_USES_CHRONO diff --git a/test/test_thread_exit.cpp b/test/test_thread_exit.cpp index 22f7d851..c940b856 100644 --- a/test/test_thread_exit.cpp +++ b/test/test_thread_exit.cpp @@ -4,10 +4,10 @@ // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include "boost/thread/thread.hpp" -#include "boost/thread/mutex.hpp" -#include "boost/thread/condition.hpp" -#include "boost/thread/future.hpp" +#include +#include +#include +#include #include #include #include diff --git a/test/test_xtime.cpp b/test/test_xtime.cpp index 50384552..2ba3013c 100644 --- a/test/test_xtime.cpp +++ b/test/test_xtime.cpp @@ -17,8 +17,8 @@ void test_xtime_cmp() { boost::xtime xt1, xt2, cur; BOOST_CHECK_EQUAL( - boost::xtime_get(&cur, boost::TIME_UTC), - static_cast(boost::TIME_UTC)); + boost::xtime_get(&cur, boost::TIME_UTC_), + static_cast(boost::TIME_UTC_)); xt1 = xt2 = cur; xt1.nsec -= 1; @@ -42,14 +42,14 @@ void test_xtime_get() boost::xtime orig, cur, old; BOOST_CHECK_EQUAL( boost::xtime_get(&orig, - boost::TIME_UTC), static_cast(boost::TIME_UTC)); + boost::TIME_UTC_), static_cast(boost::TIME_UTC_)); old = orig; for (int x=0; x < 100; ++x) { BOOST_CHECK_EQUAL( - boost::xtime_get(&cur, boost::TIME_UTC), - static_cast(boost::TIME_UTC)); + boost::xtime_get(&cur, boost::TIME_UTC_), + static_cast(boost::TIME_UTC_)); BOOST_CHECK(boost::xtime_cmp(cur, orig) >= 0); BOOST_CHECK(boost::xtime_cmp(cur, old) >= 0); old = cur; diff --git a/test/threads/this_thread/sleep_for/sleep_for_pass.cpp b/test/threads/this_thread/sleep_for/sleep_for_pass.cpp index a61ec4b8..0f1e26c9 100644 --- a/test/threads/this_thread/sleep_for/sleep_for_pass.cpp +++ b/test/threads/this_thread/sleep_for/sleep_for_pass.cpp @@ -17,6 +17,7 @@ #include #include +#include #include @@ -35,7 +36,8 @@ int main() boost::chrono::nanoseconds err = ms / 100; // The time slept is within 1% of 500ms // This test is spurious as it depends on the time the thread system switches the threads - BOOST_TEST(std::abs(static_cast(ns.count())) < (err+boost::chrono::milliseconds(1000)).count()); + BOOST_TEST(std::max(ns.count(), -ns.count()) < (err+boost::chrono::milliseconds(1000)).count()); + //BOOST_TEST(std::abs(static_cast(ns.count())) < (err+boost::chrono::milliseconds(1000)).count()); return boost::report_errors(); } diff --git a/test/threads/this_thread/sleep_until/sleep_until_pass.cpp b/test/threads/this_thread/sleep_until/sleep_until_pass.cpp index b4dd5b35..5a959d41 100644 --- a/test/threads/this_thread/sleep_until/sleep_until_pass.cpp +++ b/test/threads/this_thread/sleep_until/sleep_until_pass.cpp @@ -17,6 +17,7 @@ #include #include +#include #include @@ -35,7 +36,9 @@ int main() boost::chrono::nanoseconds err = ms / 100; // The time slept is within 1% of 500ms // This test is spurious as it depends on the time the thread system switches the threads - BOOST_TEST(std::abs(static_cast(ns.count())) < (err+boost::chrono::milliseconds(1000)).count()); + BOOST_TEST(std::max(ns.count(), -ns.count()) < (err+boost::chrono::milliseconds(1000)).count()); + //BOOST_TEST(std::abs(static_cast(ns.count())) < (err+boost::chrono::milliseconds(1000)).count()); + return boost::report_errors(); } diff --git a/test/util.inl b/test/util.inl index f96d3f36..b85fbb08 100644 --- a/test/util.inl +++ b/test/util.inl @@ -30,8 +30,8 @@ inline boost::xtime delay(int secs, int msecs=0, int nsecs=0) const int NANOSECONDS_PER_MILLISECOND = 1000000; boost::xtime xt; - if (boost::TIME_UTC != boost::xtime_get (&xt, boost::TIME_UTC)) - BOOST_ERROR ("boost::xtime_get != boost::TIME_UTC"); + if (boost::TIME_UTC_ != boost::xtime_get (&xt, boost::TIME_UTC_)) + BOOST_ERROR ("boost::xtime_get != boost::TIME_UTC_"); nsecs += xt.nsec; msecs += nsecs / NANOSECONDS_PER_MILLISECOND;