diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 31f4b091..4c250598 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -236,10 +236,7 @@ rule requirements ( properties * ) } } } - if ! vacpp in $(properties) || 11.1 in $(properties) - { - result += /boost/chrono//boost_chrono ; - } + result += BOOST_THREAD_DONT_USE_CHRONO ; return $(result) ; } diff --git a/doc/changes.qbk b/doc/changes.qbk index 9997c677..9e2cb4a2 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -8,8 +8,34 @@ [section:changes History] +[heading Version 3.1.0 - boost 1.52] + +New Features: + +* [@http://svn.boost.org/trac/boost/ticket/2361 #2361] thread_specific_ptr: document nature of the key, complexity and rationale +* [@http://svn.boost.org/trac/boost/ticket/4710 #4710] C++11 compliance: : Missing async() + +Fixed Bugs: + +* [@http://svn.boost.org/trac/boost/ticket/2797 #2797] Two problems with thread_specific_ptr +* [@http://svn.boost.org/trac/boost/ticket/5274 #5274] failed to compile future.hpp with stlport 5.1.5 under msvc8.1, because of undefined class +* [@http://svn.boost.org/trac/boost/ticket/5431 #5431] compile error in Windows CE 6.0(interlocked) +* [@http://svn.boost.org/trac/boost/ticket/5752 #5752] boost::call_once() is unreliable on some platforms +* [@http://svn.boost.org/trac/boost/ticket/5696 #5696] win32 detail::set_tss_data does nothing when tss_cleanup_function is NULL +* [@http://svn.boost.org/trac/boost/ticket/7045 #7045] Thread library does not automatically compile date_time +* [@http://svn.boost.org/trac/boost/ticket/7173 #7173] wrong function name interrupt_point() +* [@http://svn.boost.org/trac/boost/ticket/7200 #7200] Unable to build boost.thread modularized +* [@http://svn.boost.org/trac/boost/ticket/7220 #7220 7238 gcc 4.6.2 warns about inline+dllimport functions +* [@http://svn.boost.org/trac/boost/ticket/7238 #5274] this_thread::sleep_for() does not respond to interrupt() +* [@http://svn.boost.org/trac/boost/ticket/7245 #7245] Minor typos on documentation related to version 3 +* [@http://svn.boost.org/trac/boost/ticket/7272 #7272] win32/thread_primitives.hpp: (Unneccessary) Warning + [heading Version 3.0.1 - boost 1.51] +New Features: + +* [@http://svn.boost.org/trac/boost/ticket/2100 #2100] thread fails to compile with -fno-exceptions + Deprecated features since boost 1.50 available only until boost 1.55: These deprecated features will be provided by default up to boost 1.52. If you don't want to include the deprecated features you could define BOOST_THREAD_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V3_0_0. Since 1.53 these features will not be included any more by default. Since this version, if you want to include the deprecated features yet you could define BOOST_THREAD_PROVIDE_DEPRECATED_FEATURES_SINCE_V3_0_0. These deprecated features will be only available until boost 1.55, that is you have 1 year and a half to move to the new features. @@ -38,6 +64,10 @@ Fixed Bugs: * [@http://svn.boost.org/trac/boost/ticket/7078 #7078] Trivial 64-bit warning fix on Windows for thread attribute stack size * [@http://svn.boost.org/trac/boost/ticket/7089 #7089] BOOST_THREAD_WAIT_BUG limits functionality without solving anything +[/ +#6787 boost::thread::sleep() hangs if system time is rolled back +#7045 Thread library does not automatically compile date_time +] [heading Version 3.0.0 - boost 1.50] diff --git a/doc/compliance.qbk b/doc/compliance.qbk index 6f619c46..de2a4247 100644 --- a/doc/compliance.qbk +++ b/doc/compliance.qbk @@ -26,11 +26,11 @@ [[30.2.5.4] [TimedLockable requirements] [Yes] [-] [-]] [[30.2.6] [decay_copy] [-] [-] [-]] [[30.3] [Threads] [Partial] [-] [-]] - [[30.3.1] [Class thread] [Partial] [move,variadic,terminate] [#zzzz,#6270,#6269]] + [[30.3.1] [Class thread] [Partial] [move,variadic,terminate] [#6270]] [[30.3.1.1] [Class thread::id] [Yes] [-] [-]] - [[30.3.1.2] [thread constructors] [Partial] [move,variadic] [#zzzz,#6270]] - [[30.3.1.3] [thread destructor] [Partial] [terminate] [#6266]] - [[30.3.1.4] [thread assignment] [Partial] [terminate] [#6269]] + [[30.3.1.2] [thread constructors] [Partial] [move,variadic] [#6270]] + [[30.3.1.3] [thread destructor] [Yes] [-] [-]] + [[30.3.1.4] [thread assignment] [Yes] [-] [-]] [[30.3.1.5] [thread members] [Yes] [-] [-]] [[30.3.1.6] [thread static members] [Yes] [-] [-]] [[30.3.1.7] [thread specialized algorithms] [Yes] [-] [-]] @@ -53,23 +53,23 @@ [[30.4.2.2.3] [unique_lock modifiers] [Yes] [-] [-]] [[30.4.2.2.4] [unique_lock observers] [Yes] [] [-]] [[30.4.3] [Generic locking algorithms] [Partial] [variadic] [#6227]] - [[30.4.4] [Call once] [Partial] [The interface doesn't corresponds] [#6342]] - [[30.4.4.1] [Struct once_flag] [Partial] [interface] [#6342]] - [[30.4.4.2] [Function call_once] [Partial] [interface] [#6342]] - [[30.5] [Condition variables] [Partial] [notify_all_at_thread_exit] [#xxxx]] - [[30.5 6-10] [Function notify_all_at_thread_exit] [No] [-] [#xxxx]] + [[30.4.4] [Call once] [Partial] [call_once] [#7285]] + [[30.4.4.1] [Struct once_flag] [Yes] [-] [-]] + [[30.4.4.2] [Function call_once] [Partial] [interface] [#7285]] + [[30.5] [Condition variables] [Partial] [notify_all_at_thread_exit] [#7283]] + [[30.5 6-10] [Function notify_all_at_thread_exit] [No] [-] [#7283]] [[30.5.1] [Class condition_variable] [Yes] [-] [-]] [[30.5.2] [Class condition_variable_any] [Yes] [-] [-]] - [[30.6] [Futures] [Partial] [-] [-]] + [[30.6] [Futures] [Partial] [async,at_thread_exit] [#4710,#7280]] [[30.6.1] [Overview] [Partial] [-] [-]] [[30.6.2] [Error handling] [Yes] [-] [-]] - [[30.6.3] [Class future_error] [Yes] [-] [-]] + [[30.6.3] [Class future_error] [Partial] [noexcept] [#7279]] [[30.6.4] [Shared state] [-] [-] [-]] - [[30.6.5] [Class template promise] [Partial] [allocator] [#6228]] - [[30.6.6] [Class template future] [Partial] [allocator,unique_future is the closest to future, renamed in V3] [#6228]] - [[30.6.7] [Class template shared_future] [Partial] [allocator] [#6228]] - [[30.6.8] [Function template async] [No] [async] [#4710]] - [[30.6.9] [Class template packaged_task] [Partial] [move] [#yyyy]] + [[30.6.5] [Class template promise] [Partial] [at_thread_exit] [#7280]] + [[30.6.6] [Class template future] [Yes] [-] [-]] + [[30.6.7] [Class template shared_future] [Yes] [-] [-]] + [[30.6.8] [Function template async] [Partial] [deferred not implemented and only a copyable functor is allowed yet] [#4710]] + [[30.6.9] [Class template packaged_task] [Partial] [args,make_ready_at_thread_exit] [#7281,#7282]] ] [/ diff --git a/doc/configuration.qbk b/doc/configuration.qbk index a6856860..60852cea 100644 --- a/doc/configuration.qbk +++ b/doc/configuration.qbk @@ -44,7 +44,7 @@ When `BOOST_THREAD_VERSION==3` define `BOOST_THREAD_DONT_PROVIDE_GENERIC_SHARED_ [section:shared_upwards Shared Locking Upwards Conversion] -Boost.Threads includes in version 2 the Shared Locking Upwards Conversion as defined in [@http://home.roadrunner.com/~hinnant/bloomington/shared_mutex.html Shared Locking]. +Boost.Threads includes in version 3 the Shared Locking Upwards Conversion as defined in [@http://home.roadrunner.com/~hinnant/bloomington/shared_mutex.html Shared Locking]. These conversions need to be used carefully to avoid deadlock or livelock. The user need to define explicitly `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION` to get these upwards conversions. When `BOOST_THREAD_VERSION==2` define `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION ` if you want these features. @@ -201,13 +201,16 @@ Some compilers don't work correctly with some of the added features. If __SUNPRO_CC < 0x5100 the library defines * `BOOST_THREAD_DONT_USE_MOVE` + +If __SUNPRO_CC < 0x5100 the library defines + * `BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS` [endsect] [section:vacpp VACPP] -If __IBMCPP__ is defined the library defines +If __IBMCPP__ < 1100 the library defines * `BOOST_THREAD_DONT_USE_CHRONO` diff --git a/doc/future_ref.qbk b/doc/future_ref.qbk index e2762c53..6adef76a 100644 --- a/doc/future_ref.qbk +++ b/doc/future_ref.qbk @@ -61,8 +61,8 @@ class packaged_task; template void swap(packaged_task&, packaged_task&) noexcept; - //template - //struct uses_allocator, Alloc>; // NOT YET IMPLEMENTED + template + struct uses_allocator, Alloc>; // template // future::type(typename decay::type...)>::type> diff --git a/doc/overview.qbk b/doc/overview.qbk index b95a3bd2..f98ded00 100644 --- a/doc/overview.qbk +++ b/doc/overview.qbk @@ -20,7 +20,7 @@ closely follow the proposals presented to the C++ Standards Committee, in partic [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2139.html N2139], and [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2094.html N2094] -Vicente J. Botet Escriba started in version 2 the adaptation to comply with the accepted Thread C++11 library (Make use of Boost.Chrono and Boost.Move) and the [@http://home.roadrunner.com/~hinnant/bloomington/shared_mutex.html Shared Locking] Howard Hinnant proposal except for the upward conversions. +Vicente J. Botet Escriba started in version 3 the adaptation to comply with the accepted Thread C++11 library (Make use of Boost.Chrono and Boost.Move) and the [@http://home.roadrunner.com/~hinnant/bloomington/shared_mutex.html Shared Locking] Howard Hinnant proposal except for the upward conversions. Some minor features have been added also as thread attributes, reverse_lock, shared_lock_guard. In order to use the classes and functions described here, you can diff --git a/doc/shared_mutex_ref.qbk b/doc/shared_mutex_ref.qbk index 8f1b5e2d..c7a2ee46 100644 --- a/doc/shared_mutex_ref.qbk +++ b/doc/shared_mutex_ref.qbk @@ -58,6 +58,7 @@ __shared_lockable_concept__. Multiple concurrent calls to __lock_ref__, __try_lock_ref__, `__try_lock_for()`, `__try_lock_until()`, __timed_lock_ref__, __lock_shared_ref__, `__try_lock_shared_for()`, `__try_lock_shared_until()`, __try_lock_shared_ref__ and __timed_lock_shared_ref__ are permitted. +Note the the lack of reader-writer priority policies in shared_mutex. This is due to an algorithm credited to Alexander Terekhov which lets the OS decide which thread is the next to get the lock without caring whether a unique lock or shared lock is being sought. This results in a complete lack of reader or writer starvation. It is simply fair. [endsect] diff --git a/doc/thread.qbk b/doc/thread.qbk index 6e4abcc0..e36a633f 100644 --- a/doc/thread.qbk +++ b/doc/thread.qbk @@ -8,7 +8,7 @@ [library Thread [quickbook 1.5] - [version 3.0.1] + [version 3.1.0] [authors [Williams, Anthony] [Botet Escriba, Vicente J.]] [copyright 2007-11 Anthony Williams] [copyright 2011-12 Vicente J. Botet Escriba] diff --git a/doc/thread_ref.qbk b/doc/thread_ref.qbk index 3927de22..a19ed858 100644 --- a/doc/thread_ref.qbk +++ b/doc/thread_ref.qbk @@ -338,7 +338,7 @@ The user can access to some synchronization functions related to the native curr Of course all the synchronization facilities provided by Boost.Thread are also available on native threads. -The `boost::this_thread` interrupt related functions behave in a degraded mode when called from a thread created using the native interface, i.e. `boost::this_thread::interruption_enabled()` returns false. As consequence the use of `boost::this_thread::disable_interruption` and `boost::this_thread::restore_interruption` will do nothing and calls to `boost::this_thread::interrupt_point()` will be just ignored. +The `boost::this_thread` interrupt related functions behave in a degraded mode when called from a thread created using the native interface, i.e. `boost::this_thread::interruption_enabled()` returns false. As consequence the use of `boost::this_thread::disable_interruption` and `boost::this_thread::restore_interruption` will do nothing and calls to `boost::this_thread::interruption_point()` will be just ignored. As the single way to interrupt a thread is through a __thread__ instance, `interruption_request()` wiil returns false for the native threads. @@ -470,8 +470,8 @@ This behavior is incompatible with the current Boost.Thread design, so the use o [variablelist [[Effects:] [Transfers ownership of the thread managed by `other` (if -any) to `*this`. Version 1: If there was a thread previously associated with -`*this` then that thread is detached, version 2: If the thread is joinable calls to std::terminate.]] +any) to `*this`. Version 2: If there was a thread previously associated with +`*this` then that thread is detached, version 3: If the thread is joinable calls to std::terminate.]] [[Postconditions:] [`other->get_id()==thread::id()` and `get_id()` returns the value of `other.get_id()` prior to the assignment.]] diff --git a/doc/tss.qbk b/doc/tss.qbk index 150bc025..646c5a11 100644 --- a/doc/tss.qbk +++ b/doc/tss.qbk @@ -47,6 +47,10 @@ platforms such cleanup is only done for threads that are started with `boost::thread` unless `boost::on_thread_exit()` is called manually from that thread. +[heading Rational about the nature of the key] + +Boost.Thread uses the address of the `thread_specific_ptr` instance as key of the thread specific pointers. This avoids to create/destroy a key which will need a lock to protect from race conditions. This has a little performance liability, as the access must be done using an associative container. + [section:thread_specific_ptr Class `thread_specific_ptr`] #include @@ -102,10 +106,14 @@ supplied `cleanup_function` will be used to destroy any thread-local objects whe [variablelist +[[Requires:] [All the thread specific instances associated to this thread_specific_ptr (except maybe the one associated to this thread) must be null.]] + [[Effects:] [Calls `this->reset()` to clean up the associated value for the current thread, and destroys `*this`.]] [[Throws:] [Nothing.]] +[[Remarks:] [The requirement is due to the fact that in order to delete all these instances, the implementation should be forced to maintain a list of all the threads having an associated specific ptr, which is against the goal of thread specific data.]] + ] [note Care needs to be taken to ensure that any threads still running after an instance of `boost::thread_specific_ptr` has been diff --git a/include/boost/thread/detail/config.hpp b/include/boost/thread/detail/config.hpp index d9270df8..7200e20e 100644 --- a/include/boost/thread/detail/config.hpp +++ b/include/boost/thread/detail/config.hpp @@ -13,8 +13,10 @@ // This compiler doesn't support Boost.Chrono #if defined __IBMCPP__ && (__IBMCPP__ < 1100) +#if ! defined BOOST_THREAD_DONT_USE_CHRONO #define BOOST_THREAD_DONT_USE_CHRONO #endif +#endif // This compiler doesn't support Boost.Move #if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) diff --git a/include/boost/thread/detail/delete.hpp b/include/boost/thread/detail/delete.hpp index 9e56d442..30e7c932 100644 --- a/include/boost/thread/detail/delete.hpp +++ b/include/boost/thread/detail/delete.hpp @@ -15,14 +15,14 @@ * BOOST_THREAD_DELETE_COPY_ASSIGN deletes the copy assignment when the compiler supports it or * makes it private. */ -#ifndef BOOST_NO_DELETED_FUNCTIONS +#ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS #define BOOST_THREAD_DELETE_COPY_CTOR(CLASS) \ CLASS(CLASS const&) = delete; \ #define BOOST_THREAD_DELETE_COPY_ASSIGN(CLASS) \ CLASS& operator=(CLASS const&) = delete; -#else // BOOST_NO_DELETED_FUNCTIONS +#else // BOOST_NO_CXX11_DELETED_FUNCTIONS #define BOOST_THREAD_DELETE_COPY_CTOR(CLASS) \ private: \ CLASS(CLASS&); \ @@ -32,7 +32,7 @@ private: \ CLASS& operator=(CLASS&); \ public: -#endif // BOOST_NO_DELETED_FUNCTIONS +#endif // BOOST_NO_CXX11_DELETED_FUNCTIONS /** * BOOST_THREAD_NO_COPYABLE deletes the copy constructor and assignment when the compiler supports it or diff --git a/include/boost/thread/detail/memory.hpp b/include/boost/thread/detail/memory.hpp index 7d47efc7..e5fd5dc0 100644 --- a/include/boost/thread/detail/memory.hpp +++ b/include/boost/thread/detail/memory.hpp @@ -11,9 +11,15 @@ #ifndef BOOST_THREAD_DETAIL_MEMORY_HPP #define BOOST_THREAD_DETAIL_MEMORY_HPP +#include #include #include -#include +#include +#include +#include +#include +#include +#include namespace boost { @@ -48,6 +54,101 @@ namespace boost { }; + template + struct pointer_traits + { + typedef Ptr pointer; +// typedef
element_type; +// typedef
difference_type; + +// template using rebind =
; +// +// static pointer pointer_to(
); + }; + + template + struct pointer_traits + { + typedef T* pointer; + typedef T element_type; + typedef ptrdiff_t difference_type; + +// template using rebind = U*; +// +// static pointer pointer_to(
) noexcept; + }; + + + namespace thread_detail { + template ::element_type>::type, + typename remove_cv::element_type>::type + >::value + > + struct same_or_less_cv_qualified_imp + : is_convertible<_Ptr1, _Ptr2> {}; + + template + struct same_or_less_cv_qualified_imp<_Ptr1, _Ptr2, false> + : false_type {}; + + template ::value && + !is_pointer<_Ptr1>::value> + struct same_or_less_cv_qualified + : same_or_less_cv_qualified_imp<_Ptr1, _Ptr2> {}; + + template + struct same_or_less_cv_qualified<_Ptr1, _Ptr2, true> + : false_type {}; + + } + template + struct BOOST_SYMBOL_VISIBLE default_delete + { + #ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + BOOST_SYMBOL_VISIBLE + BOOST_CONSTEXPR default_delete() = default; + #else + BOOST_SYMBOL_VISIBLE + BOOST_CONSTEXPR default_delete() BOOST_NOEXCEPT {} + #endif + template + BOOST_SYMBOL_VISIBLE + default_delete(const default_delete&, + typename enable_if >::type* = 0) BOOST_NOEXCEPT {} + BOOST_SYMBOL_VISIBLE + void operator() (T* ptr) const BOOST_NOEXCEPT + { + BOOST_STATIC_ASSERT_MSG(sizeof(T) > 0, "default_delete can not delete incomplete type"); + delete ptr; + } + }; + + template + struct BOOST_SYMBOL_VISIBLE default_delete + { + public: + #ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + BOOST_SYMBOL_VISIBLE + BOOST_CONSTEXPR default_delete() = default; + #else + BOOST_SYMBOL_VISIBLE + BOOST_CONSTEXPR default_delete() BOOST_NOEXCEPT {} + #endif + template + BOOST_SYMBOL_VISIBLE + default_delete(const default_delete&, + typename enable_if >::type* = 0) BOOST_NOEXCEPT {} + template + BOOST_SYMBOL_VISIBLE + void operator() (U* ptr, + typename enable_if >::type* = 0) const BOOST_NOEXCEPT + { + BOOST_STATIC_ASSERT_MSG(sizeof(T) > 0, "default_delete can not delete incomplete type"); + delete [] ptr; + } + }; + } // namespace boost diff --git a/include/boost/thread/detail/move.hpp b/include/boost/thread/detail/move.hpp index 748b8dc2..f2665e6c 100644 --- a/include/boost/thread/detail/move.hpp +++ b/include/boost/thread/detail/move.hpp @@ -65,7 +65,7 @@ namespace boost } } -#if ! defined BOOST_NO_RVALUE_REFERENCES +#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES #define BOOST_THREAD_RV_REF(TYPE) BOOST_RV_REF(TYPE) #define BOOST_THREAD_RV_REF_BEG BOOST_RV_REF_BEG @@ -84,7 +84,7 @@ namespace boost {}; \ } -#elif ! defined BOOST_NO_RVALUE_REFERENCES && defined BOOST_MSVC +#elif ! defined BOOST_NO_CXX11_RVALUE_REFERENCES && defined BOOST_MSVC #define BOOST_THREAD_RV_REF(TYPE) BOOST_RV_REF(TYPE) #define BOOST_THREAD_RV_REF_BEG BOOST_RV_REF_BEG @@ -176,7 +176,7 @@ namespace detail #endif -#if ! defined BOOST_NO_RVALUE_REFERENCES +#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES #define BOOST_THREAD_MOVABLE(TYPE) @@ -227,7 +227,7 @@ namespace detail -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES namespace boost { namespace thread_detail { diff --git a/include/boost/thread/detail/thread.hpp b/include/boost/thread/detail/thread.hpp index 3c71b53c..712951b0 100644 --- a/include/boost/thread/detail/thread.hpp +++ b/include/boost/thread/detail/thread.hpp @@ -52,7 +52,7 @@ namespace boost { public: BOOST_THREAD_NO_COPYABLE(thread_data) -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES thread_data(BOOST_THREAD_RV_REF(F) f_): f(boost::forward(f_)) {} @@ -131,7 +131,7 @@ namespace boost detail::thread_data_ptr get_thread_info BOOST_PREVENT_MACRO_SUBSTITUTION () const; -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template static inline detail::thread_data_ptr make_thread_info(BOOST_THREAD_RV_REF(F) f) { @@ -174,7 +174,7 @@ namespace boost detach(); #endif } -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template < class F > @@ -364,11 +364,17 @@ namespace boost #endif #if defined(BOOST_THREAD_PLATFORM_WIN32) bool timed_join(const system_time& abs_time); - -#ifdef BOOST_THREAD_USES_CHRONO - bool try_join_until(const chrono::time_point& tp); -#endif + private: + bool do_try_join_until(uintmax_t milli); public: +#ifdef BOOST_THREAD_USES_CHRONO + bool try_join_until(const chrono::time_point& tp) + { + chrono::milliseconds rel_time= chrono::ceil(tp-chrono::system_clock::now()); + return do_try_join_until(rel_time.count()); + } +#endif + #else bool timed_join(const system_time& abs_time) @@ -434,7 +440,7 @@ namespace boost return lhs.swap(rhs); } -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES inline thread&& move(thread& t) BOOST_NOEXCEPT { return static_cast(t); diff --git a/include/boost/thread/future.hpp b/include/boost/thread/future.hpp index 8cad994d..ab3ae76c 100644 --- a/include/boost/thread/future.hpp +++ b/include/boost/thread/future.hpp @@ -50,7 +50,7 @@ #endif #include -//#include +#include #if defined BOOST_THREAD_PROVIDES_FUTURE #define BOOST_THREAD_FUTURE future @@ -77,7 +77,7 @@ namespace boost template <> struct BOOST_SYMBOL_VISIBLE is_error_code_enum : public true_type {}; - #ifdef BOOST_NO_SCOPED_ENUMS + #ifdef BOOST_NO_CXX11_SCOPED_ENUMS template <> struct BOOST_SYMBOL_VISIBLE is_error_code_enum : public true_type { }; #endif @@ -102,20 +102,20 @@ namespace boost BOOST_SCOPED_ENUM_DECLARE_END(future_status) BOOST_THREAD_DECL - const system::error_category& future_category(); + const system::error_category& future_category() BOOST_NOEXCEPT; namespace system { - inline BOOST_THREAD_DECL + inline error_code - make_error_code(future_errc e) + make_error_code(future_errc e) //BOOST_NOEXCEPT { return error_code(underlying_cast(e), boost::future_category()); } - inline BOOST_THREAD_DECL + inline error_condition - make_error_condition(future_errc e) + make_error_condition(future_errc e) //BOOST_NOEXCEPT { return error_condition(underlying_cast(e), future_category()); } @@ -137,14 +137,13 @@ namespace boost return ec_; } - //virtual ~future_error() BOOST_NOEXCEPT; }; class BOOST_SYMBOL_VISIBLE future_uninitialized: public future_error { public: - future_uninitialized(): + future_uninitialized() : future_error(system::make_error_code(future_errc::no_state)) {} }; @@ -179,7 +178,6 @@ namespace boost public: task_already_started(): future_error(system::make_error_code(future_errc::promise_already_satisfied)) - //std::logic_error("Task already started") {} }; @@ -189,7 +187,6 @@ namespace boost public: task_moved(): future_error(system::make_error_code(future_errc::no_state)) - //std::logic_error("Task moved") {} }; @@ -199,7 +196,6 @@ namespace boost public: promise_moved(): future_error(system::make_error_code(future_errc::no_state)) - //std::logic_error("Promise moved") {} }; @@ -374,7 +370,7 @@ namespace boost struct future_traits { typedef boost::scoped_ptr storage_type; -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES typedef T const& source_reference_type; struct dummy; typedef typename boost::mpl::if_,dummy&,BOOST_THREAD_RV_REF(T)>::type rvalue_source_type; @@ -576,7 +572,7 @@ namespace boost class future_waiter { struct registered_waiter; - typedef std::vector::size_type count_type; + typedef std::vector::size_type count_type; struct registered_waiter { @@ -1219,6 +1215,11 @@ namespace boost future_->mark_exceptional_finish_internal(p); } + // setting the result with deferred notification + //void set_value_at_thread_exit(const R& r); // NOT YET IMPLEMENTED + //void set_value_at_thread_exit(see below); // NOT YET IMPLEMENTED + //void set_exception_at_thread_exit(exception_ptr p); // NOT YET IMPLEMENTED + template void set_wait_callback(F f) { @@ -1422,7 +1423,7 @@ namespace boost task_object(F const& f_): f(f_) {} -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES task_object(BOOST_THREAD_RV_REF(F) f_): f(boost::forward(f_)) {} @@ -1459,7 +1460,7 @@ namespace boost task_object(F const& f_): f(f_) {} -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES task_object(BOOST_THREAD_RV_REF(F) f_): f(boost::forward(f_)) {} @@ -1509,7 +1510,7 @@ namespace boost explicit packaged_task(R(*f)()): task(new detail::task_object(f)),future_obtained(false) {} -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template explicit packaged_task(BOOST_THREAD_RV_REF(F) f): task(new detail::task_object(f), D(a2, 1) ); future_obtained = false; } -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template packaged_task(boost::allocator_arg_t, Allocator a, BOOST_THREAD_RV_REF(F) f) { @@ -1572,7 +1573,7 @@ namespace boost task = task_ptr(::new(a2.allocate(1)) detail::task_object(boost::move(f)), D(a2, 1) ); future_obtained = false; } -#endif //BOOST_NO_RVALUE_REFERENCES +#endif //BOOST_NO_CXX11_RVALUE_REFERENCES #endif // BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS ~packaged_task() @@ -1665,35 +1666,38 @@ 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); -// } + 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); + } else { + BOOST_THREAD_FUTURE ret; + 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 5111d33e..c11c2bd3 100644 --- a/include/boost/thread/locks.hpp +++ b/include/boost/thread/locks.hpp @@ -609,7 +609,7 @@ namespace boost is_locked=false; } -#if defined(BOOST_NO_EXPLICIT_CONVERSION_OPERATORS) +#if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) typedef void (unique_lock::*bool_type)(); operator bool_type() const BOOST_NOEXCEPT { @@ -880,7 +880,7 @@ namespace boost is_locked=false; } -#if defined(BOOST_NO_EXPLICIT_CONVERSION_OPERATORS) +#if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) typedef void (shared_lock::*bool_type)(); operator bool_type() const BOOST_NOEXCEPT { @@ -1140,7 +1140,7 @@ namespace boost return is_locked; } #endif -#if defined(BOOST_NO_EXPLICIT_CONVERSION_OPERATORS) +#if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) typedef void (upgrade_lock::*bool_type)(); operator bool_type() const BOOST_NOEXCEPT { @@ -1224,7 +1224,7 @@ namespace boost exclusive.swap(other.exclusive); } -#if defined(BOOST_NO_EXPLICIT_CONVERSION_OPERATORS) +#if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) typedef void (upgrade_to_unique_lock::*bool_type)(upgrade_to_unique_lock&); operator bool_type() const BOOST_NOEXCEPT { @@ -1275,7 +1275,7 @@ namespace boost try_lock_wrapper(Mutex& m_,try_to_lock_t): base(m_,try_to_lock) {} -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES try_lock_wrapper(BOOST_THREAD_RV_REF(try_lock_wrapper) other): base(::boost::move(other)) {} @@ -1325,7 +1325,7 @@ namespace boost return base::release(); } -#if defined(BOOST_NO_EXPLICIT_CONVERSION_OPERATORS) +#if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) typedef typename base::bool_type bool_type; operator bool_type() const { diff --git a/include/boost/thread/pthread/once.hpp b/include/boost/thread/pthread/once.hpp index 80aa09ee..5c3d0238 100644 --- a/include/boost/thread/pthread/once.hpp +++ b/include/boost/thread/pthread/once.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -25,6 +26,18 @@ namespace boost #define BOOST_ONCE_INITIAL_FLAG_VALUE 0 + namespace thread_detail + { +#ifdef SIG_ATOMIC_MAX + typedef sig_atomic_t uintmax_atomic_t; + #define BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_MAX_C SIG_ATOMIC_MAX +#else + typedef unsigned long uintmax_atomic_t; + #define BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_C2(value) value##ul + #define BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_MAX_C BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_C2(~0) +#endif + } + #ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11 struct once_flag @@ -34,7 +47,7 @@ namespace boost : epoch(BOOST_ONCE_INITIAL_FLAG_VALUE) {} private: - boost::uintmax_t epoch; + volatile thread_detail::uintmax_atomic_t epoch; template friend void call_once(once_flag& flag,Function f); @@ -44,7 +57,7 @@ namespace boost struct once_flag { - boost::uintmax_t epoch; + volatile thread_detail::uintmax_atomic_t epoch; }; #define BOOST_ONCE_INIT {BOOST_ONCE_INITIAL_FLAG_VALUE} @@ -52,8 +65,8 @@ namespace boost namespace detail { - BOOST_THREAD_DECL boost::uintmax_t& get_once_per_thread_epoch(); - BOOST_THREAD_DECL extern boost::uintmax_t once_global_epoch; + BOOST_THREAD_DECL thread_detail::uintmax_atomic_t& get_once_per_thread_epoch(); + BOOST_THREAD_DECL extern thread_detail::uintmax_atomic_t once_global_epoch; BOOST_THREAD_DECL extern pthread_mutex_t once_epoch_mutex; BOOST_THREAD_DECL extern pthread_cond_t once_epoch_cv; } @@ -63,10 +76,10 @@ namespace boost template void call_once(once_flag& flag,Function f) { - static boost::uintmax_t const uninitialized_flag=BOOST_ONCE_INITIAL_FLAG_VALUE; - static boost::uintmax_t const being_initialized=uninitialized_flag+1; - boost::uintmax_t const epoch=flag.epoch; - boost::uintmax_t& this_thread_epoch=detail::get_once_per_thread_epoch(); + static thread_detail::uintmax_atomic_t const uninitialized_flag=BOOST_ONCE_INITIAL_FLAG_VALUE; + static thread_detail::uintmax_atomic_t const being_initialized=uninitialized_flag+1; + thread_detail::uintmax_atomic_t const epoch=flag.epoch; + thread_detail::uintmax_atomic_t& this_thread_epoch=detail::get_once_per_thread_epoch(); if(epoch lk(thread_info->sleep_mutex); + while(cv_status::no_timeout==thread_info->sleep_condition.wait_for(lk,ns)) {} + } + else + { + if (ns >= nanoseconds::zero()) + { + + # if defined(BOOST_HAS_PTHREAD_DELAY_NP) + timespec ts; + ts.tv_sec = static_cast(duration_cast(ns).count()); + ts.tv_nsec = static_cast((ns - seconds(ts.tv_sec)).count()); + BOOST_VERIFY(!pthread_delay_np(&ts)); + # elif defined(BOOST_HAS_NANOSLEEP) + timespec ts; + ts.tv_sec = static_cast(duration_cast(ns).count()); + ts.tv_nsec = static_cast((ns - seconds(ts.tv_sec)).count()); + // nanosleep takes a timespec that is an offset, not + // an absolute time. + nanosleep(&ts, 0); + # else + mutex mx; + mutex::scoped_lock lock(mx); + condition_variable cond; + cond.wait_for(lock, ns); + # endif + } + } + } #endif void BOOST_THREAD_DECL yield() BOOST_NOEXCEPT; diff --git a/include/boost/thread/pthread/thread_heap_alloc.hpp b/include/boost/thread/pthread/thread_heap_alloc.hpp index 737c2985..7828318f 100644 --- a/include/boost/thread/pthread/thread_heap_alloc.hpp +++ b/include/boost/thread/pthread/thread_heap_alloc.hpp @@ -17,7 +17,7 @@ namespace boost return new T(); } -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template inline T* heap_new(A1&& a1) { @@ -72,7 +72,7 @@ namespace boost { return heap_new_impl(a1); } - + template inline T* heap_new(A1 const& a1,A2 const& a2) { @@ -218,8 +218,8 @@ namespace boost { return heap_new_impl(a1,a2,a3,a4); } - -#endif + +#endif template inline void heap_delete(T* data) { diff --git a/include/boost/thread/win32/thread_data.hpp b/include/boost/thread/win32/thread_data.hpp index 5af4fd3e..397ec143 100644 --- a/include/boost/thread/win32/thread_data.hpp +++ b/include/boost/thread/win32/thread_data.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #ifdef BOOST_THREAD_USES_CHRONO #include #endif @@ -58,8 +59,18 @@ namespace boost namespace detail { + struct tss_cleanup_function; struct thread_exit_callback_node; - struct tss_data_node; + struct tss_data_node + { + boost::shared_ptr func; + void* value; + + tss_data_node(boost::shared_ptr func_, + void* value_): + func(func_),value(value_) + {} + }; struct thread_data_base; void intrusive_ptr_add_ref(thread_data_base * p); @@ -71,14 +82,14 @@ namespace boost detail::win32::handle_manager thread_handle; detail::win32::handle_manager interruption_handle; boost::detail::thread_exit_callback_node* thread_exit_callbacks; - boost::detail::tss_data_node* tss_data; + std::map tss_data; bool interruption_enabled; unsigned id; thread_data_base(): count(0),thread_handle(detail::win32::invalid_handle_value), interruption_handle(create_anonymous_event(detail::win32::manual_reset_event,detail::win32::event_initially_reset)), - thread_exit_callbacks(0),tss_data(0), + thread_exit_callbacks(0),tss_data(), interruption_enabled(true), id(0) {} diff --git a/include/boost/thread/win32/thread_heap_alloc.hpp b/include/boost/thread/win32/thread_heap_alloc.hpp index 843e46b5..9b6d3902 100644 --- a/include/boost/thread/win32/thread_heap_alloc.hpp +++ b/include/boost/thread/win32/thread_heap_alloc.hpp @@ -91,7 +91,7 @@ namespace boost #endif } -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template inline T* heap_new(A1&& a1) { diff --git a/include/boost/thread/win32/thread_primitives.hpp b/include/boost/thread/win32/thread_primitives.hpp index 294e42ee..a68548e8 100644 --- a/include/boost/thread/win32/thread_primitives.hpp +++ b/include/boost/thread/win32/thread_primitives.hpp @@ -10,7 +10,7 @@ // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include #include #include @@ -341,7 +341,7 @@ namespace boost { inline bool interlocked_bit_test_and_set(long* x,long bit) { -#if 0 +#ifndef BOOST_INTEL_CXX_VERSION __asm { mov eax,bit; mov edx,x; @@ -349,7 +349,7 @@ namespace boost setc al; }; #else - bool ret; + bool ret=false; __asm { mov eax,bit; mov edx,x; lock bts [edx],eax; setc al; mov ret, al }; @@ -360,7 +360,7 @@ namespace boost inline bool interlocked_bit_test_and_reset(long* x,long bit) { -#if 0 +#ifndef BOOST_INTEL_CXX_VERSION __asm { mov eax,bit; mov edx,x; @@ -368,9 +368,7 @@ namespace boost setc al; }; #else - - - bool ret; + bool ret=false; __asm { mov eax,bit; mov edx,x; lock btr [edx],eax; setc al; mov ret, al }; diff --git a/src/future.cpp b/src/future.cpp index 84e823bd..33980f58 100755 --- a/src/future.cpp +++ b/src/future.cpp @@ -51,7 +51,7 @@ namespace boost } const system::error_category& - future_category() + future_category() BOOST_NOEXCEPT { static thread_detail::future_error_category f; return f; diff --git a/src/pthread/once.cpp b/src/pthread/once.cpp index a1d8a82d..d5fd6561 100644 --- a/src/pthread/once.cpp +++ b/src/pthread/once.cpp @@ -14,7 +14,7 @@ namespace boost { namespace detail { - BOOST_THREAD_DECL boost::uintmax_t once_global_epoch=UINTMAX_C(~0); + BOOST_THREAD_DECL thread_detail::uintmax_atomic_t once_global_epoch=BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_MAX_C; BOOST_THREAD_DECL pthread_mutex_t once_epoch_mutex=PTHREAD_MUTEX_INITIALIZER; BOOST_THREAD_DECL pthread_cond_t once_epoch_cv = PTHREAD_COND_INITIALIZER; @@ -55,17 +55,17 @@ namespace boost #endif } - boost::uintmax_t& get_once_per_thread_epoch() + thread_detail::uintmax_atomic_t& get_once_per_thread_epoch() { BOOST_VERIFY(!pthread_once(&epoch_tss_key_flag,create_epoch_tss_key)); void* data=pthread_getspecific(epoch_tss_key); if(!data) { - data=malloc(sizeof(boost::uintmax_t)); + data=malloc(sizeof(thread_detail::uintmax_atomic_t)); BOOST_VERIFY(!pthread_setspecific(epoch_tss_key,data)); - *static_cast(data)=UINTMAX_C(~0); + *static_cast(data)=BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_MAX_C; } - return *static_cast(data); + return *static_cast(data); } } diff --git a/src/pthread/thread.cpp b/src/pthread/thread.cpp index 2b9b95f0..e76cdf19 100644 --- a/src/pthread/thread.cpp +++ b/src/pthread/thread.cpp @@ -24,7 +24,7 @@ #include #endif -#include +#include "./timeconv.inl" namespace boost { @@ -427,33 +427,6 @@ namespace boost } } -#ifdef BOOST_THREAD_USES_CHRONO - void - sleep_for(const chrono::nanoseconds& ns) - { - using namespace chrono; - if (ns >= nanoseconds::zero()) - { - timespec ts; - ts.tv_sec = static_cast(duration_cast(ns).count()); - ts.tv_nsec = static_cast((ns - seconds(ts.tv_sec)).count()); - -# if defined(BOOST_HAS_PTHREAD_DELAY_NP) - BOOST_VERIFY(!pthread_delay_np(&ts)); -# elif defined(BOOST_HAS_NANOSLEEP) - // nanosleep takes a timespec that is an offset, not - // an absolute time. - nanosleep(&ts, 0); -# else - mutex mx; - mutex::scoped_lock lock(mx); - condition_variable cond; - cond.wait_for(lock, ns); -# endif - } - } -#endif - void yield() BOOST_NOEXCEPT { # if defined(BOOST_HAS_SCHED_YIELD) diff --git a/src/tss_null.cpp b/src/tss_null.cpp index e93ba0ff..b5029f19 100644 --- a/src/tss_null.cpp +++ b/src/tss_null.cpp @@ -8,7 +8,7 @@ #if defined(BOOST_HAS_WINTHREADS) && (defined(BOOST_THREAD_BUILD_LIB) || defined(BOOST_THREAD_TEST) || defined(UNDER_CE)) && (!defined(_MSC_VER) || defined(UNDER_CE)) -namespace boost +namespace boost { /* This file is a "null" implementation of tss cleanup; it's @@ -32,7 +32,7 @@ namespace boost longer needed and can be removed. */ } - + } #endif //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_LIB) && !defined(_MSC_VER) diff --git a/src/win32/thread.cpp b/src/win32/thread.cpp index 9b6670a6..9177786f 100644 --- a/src/win32/thread.cpp +++ b/src/win32/thread.cpp @@ -128,19 +128,6 @@ namespace boost {} }; - struct tss_data_node - { - void const* key; - boost::shared_ptr func; - void* value; - tss_data_node* next; - - tss_data_node(void const* key_,boost::shared_ptr func_,void* value_, - tss_data_node* next_): - key(key_),func(func_),value(value_),next(next_) - {} - }; - } namespace @@ -150,7 +137,7 @@ namespace boost detail::thread_data_ptr current_thread_data(get_current_thread_data(),false); if(current_thread_data) { - while(current_thread_data->tss_data || current_thread_data->thread_exit_callbacks) + while(! current_thread_data->tss_data.empty() || current_thread_data->thread_exit_callbacks) { while(current_thread_data->thread_exit_callbacks) { @@ -163,15 +150,18 @@ namespace boost } boost::detail::heap_delete(current_node); } - while(current_thread_data->tss_data) + for(std::map::iterator next=current_thread_data->tss_data.begin(), + current, + end=current_thread_data->tss_data.end(); + next!=end;) { - detail::tss_data_node* const current_node=current_thread_data->tss_data; - current_thread_data->tss_data=current_node->next; - if(current_node->func) + current=next; + ++next; + if(current->second.func && (current->second.value!=0)) { - (*current_node->func)(current_node->value); + (*current->second.func)(current->second.value); } - boost::detail::heap_delete(current_node); + current_thread_data->tss_data.erase(current); } } @@ -301,7 +291,6 @@ namespace boost { return (get_thread_info)(); } - void thread::join() { if (this_thread::get_id() == get_id()) @@ -318,45 +307,27 @@ namespace boost bool thread::timed_join(boost::system_time const& wait_until) { - if (this_thread::get_id() == get_id()) - { - boost::throw_exception(thread_resource_error(system::errc::resource_deadlock_would_occur, "boost thread: trying joining itself")); - } - detail::thread_data_ptr local_thread_info=(get_thread_info)(); - if(local_thread_info) - { - if(!this_thread::interruptible_wait(local_thread_info->thread_handle,get_milliseconds_until(wait_until))) - { - return false; - } - release_handle(); - } - return true; + return do_try_join_until(get_milliseconds_until(wait_until)); } -#ifdef BOOST_THREAD_USES_CHRONO - - bool thread::try_join_until(const chrono::time_point& tp) + bool thread::do_try_join_until(uintmax_t milli) { if (this_thread::get_id() == get_id()) { - boost::throw_exception(thread_resource_error(system::errc::resource_deadlock_would_occur, "boost thread: trying joining itself")); + boost::throw_exception(thread_resource_error(system::errc::resource_deadlock_would_occur, "boost thread: trying joining itself")); } detail::thread_data_ptr local_thread_info=(get_thread_info)(); if(local_thread_info) { - chrono::milliseconds rel_time= chrono::ceil(tp-chrono::system_clock::now()); - if(!this_thread::interruptible_wait(local_thread_info->thread_handle,rel_time.count())) - { - return false; - } - release_handle(); + if(!this_thread::interruptible_wait(local_thread_info->thread_handle,milli)) + { + return false; + } + release_handle(); } return true; } -#endif - void thread::detach() BOOST_NOEXCEPT { release_handle(); @@ -636,14 +607,11 @@ namespace boost detail::thread_data_base* const current_thread_data(get_current_thread_data()); if(current_thread_data) { - detail::tss_data_node* current_node=current_thread_data->tss_data; - while(current_node) + std::map::iterator current_node= + current_thread_data->tss_data.find(key); + if(current_node!=current_thread_data->tss_data.end()) { - if(current_node->key==key) - { - return current_node; - } - current_node=current_node->next; + return ¤t_node->second; } } return NULL; @@ -658,23 +626,43 @@ namespace boost return NULL; } - void set_tss_data(void const* key,boost::shared_ptr func,void* tss_data,bool cleanup_existing) + void add_new_tss_node(void const* key, + boost::shared_ptr func, + void* tss_data) + { + detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data()); + current_thread_data->tss_data.insert(std::make_pair(key,tss_data_node(func,tss_data))); + } + + void erase_tss_node(void const* key) + { + detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data()); + current_thread_data->tss_data.erase(key); + } + + void set_tss_data(void const* key, + boost::shared_ptr func, + void* tss_data,bool cleanup_existing) { if(tss_data_node* const current_node=find_tss_data(key)) { - if(cleanup_existing && current_node->func.get() && current_node->value) + if(cleanup_existing && current_node->func && (current_node->value!=0)) { (*current_node->func)(current_node->value); } - current_node->func=func; - current_node->value=tss_data; + if(func || (tss_data!=0)) + { + current_node->func=func; + current_node->value=tss_data; + } + else + { + erase_tss_node(key); + } } - else if(func && tss_data) + else { - detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data()); - tss_data_node* const new_node= - heap_new(key,func,tss_data,current_thread_data->tss_data); - current_thread_data->tss_data=new_node; + add_new_tss_node(key,func,tss_data); } } } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 2217a64b..352c9065 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -44,7 +44,7 @@ project clang:-pedantic clang:-Wno-long-long clang:-ansi - #clang:-fpermissive # doesn't work + #clang:-fpermissive # doesn't work gcc-mingw-4.4.0:-fdiagnostics-show-option gcc-mingw-4.5.0:-fdiagnostics-show-option @@ -80,13 +80,13 @@ rule thread-run ( sources ) rule thread-test ( sources ) { return - [ run $(sources) ../build//boost_thread : : : - /boost/test//boost_unit_test_framework/static + [ run $(sources) ../build//boost_thread : : : + /boost/test//boost_unit_test_framework/static ] [ run $(sources) ../src/tss_null.cpp ../build//boost_thread/static - : : : - /boost/test//boost_unit_test_framework/static - : $(sources[1]:B)_lib + : : : + /boost/test//boost_unit_test_framework/static + : $(sources[1]:B)_lib ] ; } @@ -178,6 +178,7 @@ rule thread-compile-fail ( sources : reqs * : name ) [ thread-test test_2309.cpp ] [ thread-run test_2501.cpp ] [ thread-test test_2741.cpp ] + [ thread-run test_3628.cpp ] [ thread-run test_4521.cpp ] [ thread-run test_4648.cpp ] [ thread-run test_4882.cpp ] @@ -188,6 +189,8 @@ rule thread-compile-fail ( sources : reqs * : name ) [ thread-run test_6130.cpp ] [ thread-run test_6170.cpp ] [ thread-run test_6174.cpp ] + [ thread-run test_7160.cpp ] + [ thread-run test_7328.cpp ] ; @@ -224,10 +227,10 @@ rule thread-compile-fail ( sources : reqs * : name ) [ thread-run2 ./sync/conditions/cv_status/cv_status_pass.cpp : cv_status__cv_status_p ] ; - #explicit ts_async ; + explicit ts_async ; test-suite ts_async : - # [ thread-run2 ./sync/futures/async/async_pass.cpp : async__async_p ] + [ thread-run2 ./sync/futures/async/async_pass.cpp : async__async_p ] ; #explicit ts_promise ; @@ -532,10 +535,4 @@ rule thread-compile-fail ( sources : reqs * : name ) [ thread-run2 ./sync/mutual_exclusion/locks/reverse_lock/types_pass.cpp : reverse_lock__types_p ] ; - explicit ts ; - test-suite ts - : - [ thread-run test_ml.cpp ] - ; - } diff --git a/test/no_implicit_assign_from_lvalue_thread.cpp b/test/no_implicit_assign_from_lvalue_thread.cpp index bf95d5d3..1922bb7d 100644 --- a/test/no_implicit_assign_from_lvalue_thread.cpp +++ b/test/no_implicit_assign_from_lvalue_thread.cpp @@ -14,14 +14,4 @@ void test() t2=t1; } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] - - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; - -} +#include "./remove_error_code_unused_warning.hpp" diff --git a/test/no_implicit_move_from_lvalue_thread.cpp b/test/no_implicit_move_from_lvalue_thread.cpp index 2e114072..63522f0f 100644 --- a/test/no_implicit_move_from_lvalue_thread.cpp +++ b/test/no_implicit_move_from_lvalue_thread.cpp @@ -13,14 +13,4 @@ void test() boost::thread t2(t1); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] - - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; - -} +#include "./remove_error_code_unused_warning.hpp" diff --git a/test/remove_error_code_unused_warning.hpp b/test/remove_error_code_unused_warning.hpp new file mode 100644 index 00000000..f6a08f23 --- /dev/null +++ b/test/remove_error_code_unused_warning.hpp @@ -0,0 +1,17 @@ +// Copyright (C) 2008 Anthony Williams +// +// 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 + +void remove_unused_warning() +{ + //../../../boost/system/error_code.hpp:214:36: warning: 'boost::system::posix_category' defined but not used [-Wunused-variable] + //../../../boost/system/error_code.hpp:215:36: warning: 'boost::system::errno_ecat' defined but not used [-Wunused-variable] + //../../../boost/system/error_code.hpp:216:36: warning: 'boost::system::native_ecat' defined but not used [-Wunused-variable] + + (void)boost::system::posix_category; + (void)boost::system::errno_ecat; + (void)boost::system::native_ecat; + +} diff --git a/test/sync/conditions/condition_variable/assign_fail.cpp b/test/sync/conditions/condition_variable/assign_fail.cpp index 586cf16e..703616ff 100644 --- a/test/sync/conditions/condition_variable/assign_fail.cpp +++ b/test/sync/conditions/condition_variable/assign_fail.cpp @@ -27,13 +27,5 @@ void fail() } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/conditions/condition_variable/copy_fail.cpp b/test/sync/conditions/condition_variable/copy_fail.cpp index 23b6e6f4..374ce316 100644 --- a/test/sync/conditions/condition_variable/copy_fail.cpp +++ b/test/sync/conditions/condition_variable/copy_fail.cpp @@ -26,13 +26,5 @@ void fail() boost::condition_variable cv1(cv0); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/conditions/condition_variable_any/assign_fail.cpp b/test/sync/conditions/condition_variable_any/assign_fail.cpp index 0329598e..6dba459c 100644 --- a/test/sync/conditions/condition_variable_any/assign_fail.cpp +++ b/test/sync/conditions/condition_variable_any/assign_fail.cpp @@ -26,13 +26,5 @@ void fail() cv1 = cv0; } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/conditions/condition_variable_any/copy_fail.cpp b/test/sync/conditions/condition_variable_any/copy_fail.cpp index 0b2e0ad7..71d3a3f0 100644 --- a/test/sync/conditions/condition_variable_any/copy_fail.cpp +++ b/test/sync/conditions/condition_variable_any/copy_fail.cpp @@ -26,13 +26,5 @@ void fail() boost::condition_variable_any cv1(cv0); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/futures/async/async_pass.cpp b/test/sync/futures/async/async_pass.cpp index a41aea56..dee44a6a 100644 --- a/test/sync/futures/async/async_pass.cpp +++ b/test/sync/futures/async/async_pass.cpp @@ -22,6 +22,7 @@ // future::type> // async(launch policy, F&& f, Args&&... args); +#define BOOST_THREAD_VERSION 3 #include #include @@ -51,17 +52,17 @@ void f2() boost::this_thread::sleep_for(ms(200)); } -boost::interprocess::unique_ptr f3(int i) +boost::interprocess::unique_ptr > f3(int i) { boost::this_thread::sleep_for(ms(200)); - return boost::interprocess::unique_ptr(new int(i)); + return boost::interprocess::unique_ptr >(new int(i)); } -boost::interprocess::unique_ptr f4(boost::interprocess::unique_ptr&& p) -{ - boost::this_thread::sleep_for(ms(200)); - return boost::move(p); -} +//boost::interprocess::unique_ptr > f4(boost::interprocess::unique_ptr >&& p) +//{ +// boost::this_thread::sleep_for(ms(200)); +// return boost::move(p); +//} int main() { @@ -89,15 +90,15 @@ int main() Clock::time_point t1 = Clock::now(); BOOST_TEST(t1 - t0 < ms(100)); } - { - boost::future f = boost::async(boost::launch::deferred, f0); - boost::this_thread::sleep_for(ms(300)); - Clock::time_point t0 = Clock::now(); - BOOST_TEST(f.get() == 3); - Clock::time_point t1 = Clock::now(); - BOOST_TEST(t1 - t0 > ms(100)); - } - +// { +// boost::future f = boost::async(boost::launch::deferred, f0); +// boost::this_thread::sleep_for(ms(300)); +// Clock::time_point t0 = Clock::now(); +// BOOST_TEST(f.get() == 3); +// Clock::time_point t1 = Clock::now(); +// BOOST_TEST(t1 - t0 > ms(100)); +// } +// { boost::future f = boost::async(f1); boost::this_thread::sleep_for(ms(300)); @@ -122,15 +123,15 @@ int main() Clock::time_point t1 = Clock::now(); BOOST_TEST(t1 - t0 < ms(100)); } - { - boost::future f = boost::async(boost::launch::deferred, f1); - boost::this_thread::sleep_for(ms(300)); - Clock::time_point t0 = Clock::now(); - BOOST_TEST(&f.get() == &i); - Clock::time_point t1 = Clock::now(); - BOOST_TEST(t1 - t0 > ms(100)); - } - +// { +// boost::future f = boost::async(boost::launch::deferred, f1); +// boost::this_thread::sleep_for(ms(300)); +// Clock::time_point t0 = Clock::now(); +// BOOST_TEST(&f.get() == &i); +// Clock::time_point t1 = Clock::now(); +// BOOST_TEST(t1 - t0 > ms(100)); +// } +// { boost::future f = boost::async(f2); boost::this_thread::sleep_for(ms(300)); @@ -155,32 +156,32 @@ int main() Clock::time_point t1 = Clock::now(); BOOST_TEST(t1 - t0 < ms(100)); } - { - boost::future f = boost::async(boost::launch::deferred, f2); - boost::this_thread::sleep_for(ms(300)); - Clock::time_point t0 = Clock::now(); - f.get(); - Clock::time_point t1 = Clock::now(); - BOOST_TEST(t1 - t0 > ms(100)); - } +// { +// boost::future f = boost::async(boost::launch::deferred, f2); +// boost::this_thread::sleep_for(ms(300)); +// Clock::time_point t0 = Clock::now(); +// f.get(); +// Clock::time_point t1 = Clock::now(); +// BOOST_TEST(t1 - t0 > ms(100)); +// } - { - 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); - Clock::time_point t1 = Clock::now(); - BOOST_TEST(t1 - t0 < ms(100)); - } +// { +// 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); +// Clock::time_point t1 = Clock::now(); +// BOOST_TEST(t1 - t0 < ms(100)); +// } - { - 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); - Clock::time_point t1 = Clock::now(); - BOOST_TEST(t1 - t0 < ms(100)); - } +// { +// 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); +// Clock::time_point t1 = Clock::now(); +// BOOST_TEST(t1 - t0 < ms(100)); +// } return boost::report_errors(); } diff --git a/test/sync/futures/future/copy_assign_fail.cpp b/test/sync/futures/future/copy_assign_fail.cpp index 3c08aaf2..170f3a05 100755 --- a/test/sync/futures/future/copy_assign_fail.cpp +++ b/test/sync/futures/future/copy_assign_fail.cpp @@ -36,13 +36,5 @@ int main() return boost::report_errors(); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/futures/future/copy_ctor_fail.cpp b/test/sync/futures/future/copy_ctor_fail.cpp index b8fed11a..3a16afd5 100644 --- a/test/sync/futures/future/copy_ctor_fail.cpp +++ b/test/sync/futures/future/copy_ctor_fail.cpp @@ -34,13 +34,5 @@ int main() return boost::report_errors(); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/futures/future/dtor_pass.cpp b/test/sync/futures/future/dtor_pass.cpp index d1873f12..3d972204 100755 --- a/test/sync/futures/future/dtor_pass.cpp +++ b/test/sync/futures/future/dtor_pass.cpp @@ -24,7 +24,7 @@ #include #include #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS -#include +#include "../test_allocator.hpp" #endif int main() diff --git a/test/sync/futures/packaged_task/alloc_ctor_pass.cpp b/test/sync/futures/packaged_task/alloc_ctor_pass.cpp index 6b5dac1c..a1f82655 100644 --- a/test/sync/futures/packaged_task/alloc_ctor_pass.cpp +++ b/test/sync/futures/packaged_task/alloc_ctor_pass.cpp @@ -25,7 +25,7 @@ #include #include #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS -#include +#include "../test_allocator.hpp" double fct() { diff --git a/test/sync/futures/packaged_task/copy_assign_fail.cpp b/test/sync/futures/packaged_task/copy_assign_fail.cpp index 890a2d56..6b1f861c 100755 --- a/test/sync/futures/packaged_task/copy_assign_fail.cpp +++ b/test/sync/futures/packaged_task/copy_assign_fail.cpp @@ -45,13 +45,5 @@ int main() return boost::report_errors(); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/futures/packaged_task/copy_ctor_fail.cpp b/test/sync/futures/packaged_task/copy_ctor_fail.cpp index 206c1f79..30bad1e2 100644 --- a/test/sync/futures/packaged_task/copy_ctor_fail.cpp +++ b/test/sync/futures/packaged_task/copy_ctor_fail.cpp @@ -45,13 +45,5 @@ int main() return boost::report_errors(); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/futures/packaged_task/use_allocator_pass.cpp b/test/sync/futures/packaged_task/use_allocator_pass.cpp index f3e2f420..9d582814 100644 --- a/test/sync/futures/packaged_task/use_allocator_pass.cpp +++ b/test/sync/futures/packaged_task/use_allocator_pass.cpp @@ -28,7 +28,7 @@ #include #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS -#include +#include "../test_allocator.hpp" int main() { diff --git a/test/sync/futures/promise/alloc_ctor_pass.cpp b/test/sync/futures/promise/alloc_ctor_pass.cpp index 55c86a79..0d0c3c0b 100644 --- a/test/sync/futures/promise/alloc_ctor_pass.cpp +++ b/test/sync/futures/promise/alloc_ctor_pass.cpp @@ -23,7 +23,7 @@ #include #include #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS -#include +#include "../test_allocator.hpp" int main() { diff --git a/test/sync/futures/promise/copy_assign_fail.cpp b/test/sync/futures/promise/copy_assign_fail.cpp index 4625477f..07895578 100755 --- a/test/sync/futures/promise/copy_assign_fail.cpp +++ b/test/sync/futures/promise/copy_assign_fail.cpp @@ -31,13 +31,5 @@ int main() return boost::report_errors(); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/futures/promise/copy_ctor_fail.cpp b/test/sync/futures/promise/copy_ctor_fail.cpp index 8cfcfdfc..cfd67a6d 100644 --- a/test/sync/futures/promise/copy_ctor_fail.cpp +++ b/test/sync/futures/promise/copy_ctor_fail.cpp @@ -30,13 +30,5 @@ int main() return boost::report_errors(); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/futures/promise/move_assign_pass.cpp b/test/sync/futures/promise/move_assign_pass.cpp index d41c9a7c..0190527c 100755 --- a/test/sync/futures/promise/move_assign_pass.cpp +++ b/test/sync/futures/promise/move_assign_pass.cpp @@ -23,7 +23,7 @@ #include #include #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS -#include +#include "../test_allocator.hpp" #endif boost::mutex m0; diff --git a/test/sync/futures/promise/move_ctor_pass.cpp b/test/sync/futures/promise/move_ctor_pass.cpp index 44edaa49..a72eb182 100755 --- a/test/sync/futures/promise/move_ctor_pass.cpp +++ b/test/sync/futures/promise/move_ctor_pass.cpp @@ -23,7 +23,7 @@ #include #include #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS -#include +#include "../test_allocator.hpp" #endif boost::mutex m; diff --git a/test/sync/futures/promise/use_allocator_pass.cpp b/test/sync/futures/promise/use_allocator_pass.cpp index c11c06b3..d8a6522b 100644 --- a/test/sync/futures/promise/use_allocator_pass.cpp +++ b/test/sync/futures/promise/use_allocator_pass.cpp @@ -25,7 +25,7 @@ #include #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS -#include +#include "../test_allocator.hpp" int main() { diff --git a/test/sync/mutual_exclusion/locks/lock_guard/copy_assign_fail.cpp b/test/sync/mutual_exclusion/locks/lock_guard/copy_assign_fail.cpp index 5e90b4b3..528ed978 100755 --- a/test/sync/mutual_exclusion/locks/lock_guard/copy_assign_fail.cpp +++ b/test/sync/mutual_exclusion/locks/lock_guard/copy_assign_fail.cpp @@ -33,13 +33,5 @@ int main() } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/locks/lock_guard/copy_ctor_fail.cpp b/test/sync/mutual_exclusion/locks/lock_guard/copy_ctor_fail.cpp index 81b22381..135a162a 100755 --- a/test/sync/mutual_exclusion/locks/lock_guard/copy_ctor_fail.cpp +++ b/test/sync/mutual_exclusion/locks/lock_guard/copy_ctor_fail.cpp @@ -32,13 +32,5 @@ int main() boost::lock_guard lk1 = lk0; } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/locks/reverse_lock/copy_assign_fail.cpp b/test/sync/mutual_exclusion/locks/reverse_lock/copy_assign_fail.cpp index 77808fc0..0a15a149 100755 --- a/test/sync/mutual_exclusion/locks/reverse_lock/copy_assign_fail.cpp +++ b/test/sync/mutual_exclusion/locks/reverse_lock/copy_assign_fail.cpp @@ -29,13 +29,5 @@ int main() } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/locks/reverse_lock/copy_ctor_fail.cpp b/test/sync/mutual_exclusion/locks/reverse_lock/copy_ctor_fail.cpp index a5e23484..bdc51007 100755 --- a/test/sync/mutual_exclusion/locks/reverse_lock/copy_ctor_fail.cpp +++ b/test/sync/mutual_exclusion/locks/reverse_lock/copy_ctor_fail.cpp @@ -28,13 +28,5 @@ int main() } } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_assign_fail.cpp b/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_assign_fail.cpp index 55ef440c..015e2af5 100755 --- a/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_assign_fail.cpp +++ b/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_assign_fail.cpp @@ -37,13 +37,5 @@ int main() } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_ctor_fail.cpp b/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_ctor_fail.cpp index 1756a633..b24b4442 100755 --- a/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_ctor_fail.cpp +++ b/test/sync/mutual_exclusion/locks/shared_lock/cons/copy_ctor_fail.cpp @@ -36,13 +36,5 @@ int main() BOOST_TEST(lk0.owns_lock() == false); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_assign_fail.cpp b/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_assign_fail.cpp index 4f68b2ef..43607ac2 100755 --- a/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_assign_fail.cpp +++ b/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_assign_fail.cpp @@ -33,13 +33,5 @@ int main() } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_ctor_fail.cpp b/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_ctor_fail.cpp index a6659ab0..a7d4f006 100755 --- a/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_ctor_fail.cpp +++ b/test/sync/mutual_exclusion/locks/shared_lock_guard/copy_ctor_fail.cpp @@ -32,13 +32,5 @@ int main() boost::shared_lock_guard lk1 = lk0; } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_assign_fail.cpp b/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_assign_fail.cpp index 58227670..43b26e2a 100644 --- a/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_assign_fail.cpp +++ b/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_assign_fail.cpp @@ -37,13 +37,5 @@ int main() } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_ctor_fail.cpp b/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_ctor_fail.cpp index 4f666be2..8fb0aaab 100644 --- a/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_ctor_fail.cpp +++ b/test/sync/mutual_exclusion/locks/unique_lock/cons/copy_ctor_fail.cpp @@ -36,13 +36,5 @@ int main() BOOST_TEST(lk0.owns_lock() == false); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/locks/unique_lock/obs/op_int_fail.cpp b/test/sync/mutual_exclusion/locks/unique_lock/obs/op_int_fail.cpp index a4d46ec5..ffa3e53e 100644 --- a/test/sync/mutual_exclusion/locks/unique_lock/obs/op_int_fail.cpp +++ b/test/sync/mutual_exclusion/locks/unique_lock/obs/op_int_fail.cpp @@ -35,13 +35,5 @@ int main() return boost::report_errors(); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_assign_fail.cpp b/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_assign_fail.cpp index a33c5e6b..a2e7c61f 100755 --- a/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_assign_fail.cpp +++ b/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_assign_fail.cpp @@ -37,13 +37,5 @@ int main() } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_ctor_fail.cpp b/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_ctor_fail.cpp index 1a8557a5..b6a92f8e 100755 --- a/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_ctor_fail.cpp +++ b/test/sync/mutual_exclusion/locks/upgrade_lock/cons/copy_ctor_fail.cpp @@ -36,13 +36,5 @@ int main() BOOST_TEST(lk0.owns_lock() == false); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/mutex/assign_fail.cpp b/test/sync/mutual_exclusion/mutex/assign_fail.cpp index 1ec3b217..fa1aff9b 100644 --- a/test/sync/mutual_exclusion/mutex/assign_fail.cpp +++ b/test/sync/mutual_exclusion/mutex/assign_fail.cpp @@ -27,13 +27,5 @@ int main() boost::mutex m1(m0); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/mutex/copy_fail.cpp b/test/sync/mutual_exclusion/mutex/copy_fail.cpp index 7966ebd4..e6f6d6b8 100644 --- a/test/sync/mutual_exclusion/mutex/copy_fail.cpp +++ b/test/sync/mutual_exclusion/mutex/copy_fail.cpp @@ -27,13 +27,5 @@ int main() boost::mutex m1(m0); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/recursive_mutex/assign_fail.cpp b/test/sync/mutual_exclusion/recursive_mutex/assign_fail.cpp index 6279734a..041102e9 100644 --- a/test/sync/mutual_exclusion/recursive_mutex/assign_fail.cpp +++ b/test/sync/mutual_exclusion/recursive_mutex/assign_fail.cpp @@ -27,13 +27,5 @@ int main() boost::recursive_mutex m1(m0); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/recursive_mutex/copy_fail.cpp b/test/sync/mutual_exclusion/recursive_mutex/copy_fail.cpp index d2e657e3..932422d1 100644 --- a/test/sync/mutual_exclusion/recursive_mutex/copy_fail.cpp +++ b/test/sync/mutual_exclusion/recursive_mutex/copy_fail.cpp @@ -27,13 +27,5 @@ int main() boost::recursive_mutex m1(m0); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/recursive_timed_mutex/assign_fail.cpp b/test/sync/mutual_exclusion/recursive_timed_mutex/assign_fail.cpp index 18e24533..48b9cc47 100644 --- a/test/sync/mutual_exclusion/recursive_timed_mutex/assign_fail.cpp +++ b/test/sync/mutual_exclusion/recursive_timed_mutex/assign_fail.cpp @@ -27,13 +27,4 @@ int main() boost::recursive_timed_mutex m1(m0); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] - - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} +#include "../../../remove_error_code_unused_warning.hpp" diff --git a/test/sync/mutual_exclusion/recursive_timed_mutex/copy_fail.cpp b/test/sync/mutual_exclusion/recursive_timed_mutex/copy_fail.cpp index 9970a279..b4e96c7a 100644 --- a/test/sync/mutual_exclusion/recursive_timed_mutex/copy_fail.cpp +++ b/test/sync/mutual_exclusion/recursive_timed_mutex/copy_fail.cpp @@ -27,13 +27,5 @@ int main() boost::recursive_timed_mutex m1(m0); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/shared_mutex/assign_fail.cpp b/test/sync/mutual_exclusion/shared_mutex/assign_fail.cpp index 1b2f0b17..ee6446d7 100755 --- a/test/sync/mutual_exclusion/shared_mutex/assign_fail.cpp +++ b/test/sync/mutual_exclusion/shared_mutex/assign_fail.cpp @@ -27,13 +27,5 @@ int main() boost::shared_mutex m1(m0); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} diff --git a/test/sync/mutual_exclusion/shared_mutex/copy_fail.cpp b/test/sync/mutual_exclusion/shared_mutex/copy_fail.cpp index 38e91a0b..9627f9f6 100755 --- a/test/sync/mutual_exclusion/shared_mutex/copy_fail.cpp +++ b/test/sync/mutual_exclusion/shared_mutex/copy_fail.cpp @@ -27,15 +27,6 @@ int main() boost::shared_mutex m1(m0); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; - -} diff --git a/test/sync/mutual_exclusion/timed_mutex/assign_fail.cpp b/test/sync/mutual_exclusion/timed_mutex/assign_fail.cpp index 9ad3da7f..2ef77c8f 100644 --- a/test/sync/mutual_exclusion/timed_mutex/assign_fail.cpp +++ b/test/sync/mutual_exclusion/timed_mutex/assign_fail.cpp @@ -27,14 +27,5 @@ int main() boost::timed_mutex m1(m0); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "impl/thread/test/remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; - -} diff --git a/test/sync/mutual_exclusion/timed_mutex/copy_fail.cpp b/test/sync/mutual_exclusion/timed_mutex/copy_fail.cpp index 550d2686..08b9393d 100644 --- a/test/sync/mutual_exclusion/timed_mutex/copy_fail.cpp +++ b/test/sync/mutual_exclusion/timed_mutex/copy_fail.cpp @@ -27,13 +27,4 @@ int main() boost::timed_mutex m1(m0); } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] - - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; -} +#include "impl/thread/test/remove_error_code_unused_warning.hpp" diff --git a/test/test_2309.cpp b/test/test_2309.cpp index a33c1e50..1d1c3e55 100755 --- a/test/test_2309.cpp +++ b/test/test_2309.cpp @@ -9,54 +9,54 @@ #include - using namespace std; + using namespace std; - boost::mutex mutex_; + boost::mutex mutex_; - void perform() - { - try - { - boost::this_thread::sleep(boost::posix_time::seconds(100)); - } - catch (boost::thread_interrupted& interrupt) - { - boost::mutex::scoped_lock lock(mutex_); - cerr << "Thread " << boost::this_thread::get_id() << " got interrupted" << endl; - throw(interrupt); - } - catch (std::exception& e) - { - boost::mutex::scoped_lock lock(mutex_); - cerr << "Thread " << boost::this_thread::get_id() << " caught std::exception" << e.what() << endl; - } - catch (...) - { - boost::mutex::scoped_lock lock(mutex_); - cerr << "Thread " << boost::this_thread::get_id() << " caught something else" << endl; - } - } + void perform() + { + try + { + boost::this_thread::sleep(boost::posix_time::seconds(100)); + } + catch (boost::thread_interrupted& interrupt) + { + boost::mutex::scoped_lock lock(mutex_); + cerr << "Thread " << boost::this_thread::get_id() << " got interrupted" << endl; + throw(interrupt); + } + catch (std::exception& e) + { + boost::mutex::scoped_lock lock(mutex_); + cerr << "Thread " << boost::this_thread::get_id() << " caught std::exception" << e.what() << endl; + } + catch (...) + { + boost::mutex::scoped_lock lock(mutex_); + cerr << "Thread " << boost::this_thread::get_id() << " caught something else" << endl; + } + } - void test() - { + void test() + { try { boost::thread_group threads; - for (int i = 0; i < 2; ++i) - { - threads.create_thread(perform); - } + for (int i = 0; i < 2; ++i) + { + threads.create_thread(perform); + } - //boost::this_thread::sleep(1); - threads.interrupt_all(); - threads.join_all(); + //boost::this_thread::sleep(1); + threads.interrupt_all(); + threads.join_all(); } catch (...) { BOOST_CHECK(false && "exception raised"); } - } + } boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[]) { diff --git a/test/test_2501.cpp b/test/test_2501.cpp index 4a226371..c654e727 100644 --- a/test/test_2501.cpp +++ b/test/test_2501.cpp @@ -1,3 +1,8 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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 #include diff --git a/test/test_2741.cpp b/test/test_2741.cpp index cbe3253e..cccf0462 100644 --- a/test/test_2741.cpp +++ b/test/test_2741.cpp @@ -15,7 +15,7 @@ #include #define DEFAULT_EXECUTION_MONITOR_TYPE execution_monitor::use_sleep_only -#include +#include "./util.inl" int test_value; #ifdef PTHREAD_STACK_MIN diff --git a/test/test_3628.cpp b/test/test_3628.cpp new file mode 100644 index 00000000..72256545 --- /dev/null +++ b/test/test_3628.cpp @@ -0,0 +1,89 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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 +#include +#include +#include +#include + +using namespace std; + +boost::recursive_mutex theMutex; + +typedef std::list Conditions; +Conditions theConditions; + +void ThreadFuncWaiter() +{ + boost::condition con1; + //for(; ; ) + for (int j = 0; j < 10; j++) + { + { + boost::recursive_mutex::scoped_lock lockMtx(theMutex); + theConditions.push_back(&con1); + + cout << "Added " << boost::this_thread::get_id() << " " << &con1 << endl; + if (con1.timed_wait(lockMtx, boost::posix_time::time_duration(0, 0, 50))) + { + cout << "Woke Up " << boost::this_thread::get_id() << " " << &con1 << endl; + } + else + { + cout << "*****Timed Out " << boost::this_thread::get_id() << " " << &con1 << endl; + exit(13); + } + + theConditions.remove(&con1); + cout << "Removed " << boost::this_thread::get_id() << " " << &con1 << endl; + cout << "Waiter " << j << endl; + + } + //Sleep(2000); + boost::this_thread::sleep_for(boost::chrono::milliseconds(200)); + } +} + +void ThreadFuncNotifier() +{ + for (int j = 0; j < 70; j++) + { + { + boost::recursive_mutex::scoped_lock lockMtx(theMutex); + cout << "notify_one(); + //WORKAROUND_ lockMtx.unlock(); + //WORKAROUND_ boost::this_thread::sleep_for(boost::chrono::milliseconds(50)); + cout << "Notified One " << theConditions.size() << " " << (*it) << endl; + ++i; + //WORKAROUND_ lockMtx.lock(); + } + + cout << "Notifier> " << j << endl; + } + boost::this_thread::sleep_for(boost::chrono::milliseconds(50)); + } +} + +int main() +{ + boost::thread_group tg; + for (int i = 0; i < 12; ++i) + { + tg.create_thread(ThreadFuncWaiter); + } + + tg.create_thread(ThreadFuncNotifier); + + tg.join_all(); + + return 0; +} + diff --git a/test/test_3837.cpp b/test/test_3837.cpp new file mode 100644 index 00000000..97036cd2 --- /dev/null +++ b/test/test_3837.cpp @@ -0,0 +1,72 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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 +#include +#include +#include + +using namespace boost; +using namespace boost::chrono; + +struct dummy_class_tracks_deletions +{ + static unsigned deletions; + + dummy_class_tracks_deletions() + { + std::cout << __FILE__ << ":" << __LINE__ << boost::this_thread::get_id() << std::endl; + } + ~dummy_class_tracks_deletions() + { + ++deletions; + std::cout << __FILE__ << ":" << __LINE__ << boost::this_thread::get_id() << std::endl; + } + +}; +unsigned dummy_class_tracks_deletions::deletions=0; + + +optional > optr; +//struct X +//{ +// thread_specific_ptr f; +//} sptr; + +void other_thread() +{ + + std::cout << __FILE__ << ":" << __LINE__ << boost::this_thread::get_id() << std::endl; + optr = none; + std::cout << __FILE__ << ":" << __LINE__ << boost::this_thread::get_id() << std::endl; + optr = in_place(); + std::cout << __FILE__ << ":" << __LINE__ << boost::this_thread::get_id() << std::endl; + BOOST_TEST(optr->get() == 0); + this_thread::sleep(posix_time::seconds(5)); + BOOST_TEST(optr->get() == 0); + std::cout << __FILE__ << ":" << __LINE__ << boost::this_thread::get_id() << std::endl; + +} + +int main() +{ + + std::cout << __FILE__ << ":" << __LINE__ << boost::this_thread::get_id() << std::endl; + dummy_class_tracks_deletions * pi = new dummy_class_tracks_deletions; + std::cout << __FILE__ << ":" << __LINE__ << boost::this_thread::get_id() << std::endl; + optr = in_place(); + std::cout << __FILE__ << ":" << __LINE__ << boost::this_thread::get_id() << std::endl; + optr->reset(pi); + std::cout << __FILE__ << ":" << __LINE__ << boost::this_thread::get_id() << std::endl; + BOOST_TEST(optr->get() == pi); + thread t1(bind(&other_thread)); + this_thread::sleep(posix_time::seconds(5)); + std::cout << __FILE__ << ":" << __LINE__ << boost::this_thread::get_id() << std::endl; + BOOST_TEST(optr->get() == pi); + std::cout << __FILE__ << ":" << __LINE__ << boost::this_thread::get_id() << std::endl; + t1.join(); + return boost::report_errors(); + +} diff --git a/test/test_4521.cpp b/test/test_4521.cpp index ae16219e..c7aeacdb 100644 --- a/test/test_4521.cpp +++ b/test/test_4521.cpp @@ -1,3 +1,8 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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 int calculate_the_answer_to_life_the_universe_and_everything() diff --git a/test/test_4648.cpp b/test/test_4648.cpp index 1ece3df0..6a929b5f 100644 --- a/test/test_4648.cpp +++ b/test/test_4648.cpp @@ -1,3 +1,8 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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 #include #include diff --git a/test/test_4882.cpp b/test/test_4882.cpp index 2c9d031f..1ccdb1c5 100644 --- a/test/test_4882.cpp +++ b/test/test_4882.cpp @@ -1,3 +1,8 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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 #include diff --git a/test/test_5351.cpp b/test/test_5351.cpp index 8ce10ac7..48d19658 100644 --- a/test/test_5351.cpp +++ b/test/test_5351.cpp @@ -1,3 +1,8 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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 #include #include diff --git a/test/test_5502.cpp b/test/test_5502.cpp index 4a29934f..12bd6490 100644 --- a/test/test_5502.cpp +++ b/test/test_5502.cpp @@ -1,3 +1,8 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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) + // bm.cpp // g++ test.cpp -lboost_thread-mt && ./a.out diff --git a/test/test_5542_1.cpp b/test/test_5542_1.cpp index dcd1ab97..256ba34d 100644 --- a/test/test_5542_1.cpp +++ b/test/test_5542_1.cpp @@ -1,3 +1,8 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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 #include diff --git a/test/test_5542_2.cpp b/test/test_5542_2.cpp index c48ef4ea..39a6142b 100644 --- a/test/test_5542_2.cpp +++ b/test/test_5542_2.cpp @@ -1,3 +1,8 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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 void run_thread() { diff --git a/test/test_5542_3.cpp b/test/test_5542_3.cpp index ea80f04c..792bf1d0 100644 --- a/test/test_5542_3.cpp +++ b/test/test_5542_3.cpp @@ -1,3 +1,8 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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 #include #include diff --git a/test/test_6130.cpp b/test/test_6130.cpp index e77f9c3c..d8e84c34 100644 --- a/test/test_6130.cpp +++ b/test/test_6130.cpp @@ -1,4 +1,10 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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 +#include #include #include #include @@ -29,6 +35,9 @@ int main() std::cerr << "now_time =" << now_time << " \n"; std::cerr << "end_time =" << end_time << " \n"; std::cerr << "wait_time=" << wait_time << " \n"; + std::cerr << "now_time =" << from_time_t(now_time) << " \n"; + std::cerr << "end_time =" << from_time_t(end_time) << " \n"; + std::cerr << "wait_time=" << from_time_t(wait_time) << " \n"; std::cerr << end_time - wait_time << " \n"; assert(end_time >= wait_time); std::cerr << " OK\n"; diff --git a/test/test_6170.cpp b/test/test_6170.cpp index 4c019074..5ddb21e6 100644 --- a/test/test_6170.cpp +++ b/test/test_6170.cpp @@ -1,3 +1,8 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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 #include diff --git a/test/test_7160.cpp b/test/test_7160.cpp new file mode 100644 index 00000000..757043e1 --- /dev/null +++ b/test/test_7160.cpp @@ -0,0 +1,37 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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) + +#define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + +#include +#include + +class ThreadClass +{ + public: + ThreadClass() + { + } + + void operator()() + { + return; + } +}; + + +int main() +{ + boost::posix_time::ptime currentTimeUTC; + + ThreadClass tc; + boost::thread t(tc); + t.join(); //causes a runtime access violation here + + std::cout << "done" << std::endl; + //system("pause"); + + return 0; +} diff --git a/test/test_7328.cpp b/test/test_7328.cpp new file mode 100644 index 00000000..87ad8708 --- /dev/null +++ b/test/test_7328.cpp @@ -0,0 +1,39 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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 +#include +#include + +//using namespace boost; +using namespace boost::chrono; + +bool interrupted = false; +void f() +{ + try + { + std::cout << "Starting sleep in thread" << std::endl; + while (true) + { + boost::this_thread::sleep_for(seconds(60)); + } + } + catch (const boost::thread_interrupted&) + { + interrupted = true; + std::cout << "Thread interrupted." << std::endl; + } +} + +int main() +{ + boost::thread t(f); + t.interrupt(); + t.join(); + std::cout << "Joined with thread." << std::endl; + BOOST_TEST(interrupted); + return boost::report_errors(); +} diff --git a/test/test_condition.cpp b/test/test_condition.cpp index 209c72e0..f26a9d16 100644 --- a/test/test_condition.cpp +++ b/test/test_condition.cpp @@ -13,7 +13,7 @@ #include -#include +#include "./util.inl" struct condition_test_data { diff --git a/test/test_condition_notify_all.cpp b/test/test_condition_notify_all.cpp index aaae066a..0066576e 100644 --- a/test/test_condition_notify_all.cpp +++ b/test/test_condition_notify_all.cpp @@ -9,8 +9,8 @@ #include -#include -#include +#include "./util.inl" +#include "./condition_test_common.hpp" unsigned const number_of_test_threads=5; diff --git a/test/test_condition_notify_one.cpp b/test/test_condition_notify_one.cpp index fbee012c..06ebcf86 100644 --- a/test/test_condition_notify_one.cpp +++ b/test/test_condition_notify_one.cpp @@ -9,8 +9,8 @@ #include -#include -#include +#include "./util.inl" +#include "./condition_test_common.hpp" 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 03391410..b4e13949 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 +#include "./util.inl" bool fake_predicate() { diff --git a/test/test_ml.cpp b/test/test_ml.cpp index 08707c23..51268d3d 100755 --- a/test/test_ml.cpp +++ b/test/test_ml.cpp @@ -1,3 +1,8 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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 #ifndef BOOST_NO_RVALUE_REFERENCES diff --git a/test/test_mutex.cpp b/test/test_mutex.cpp index 68a982d9..b2e14aa1 100644 --- a/test/test_mutex.cpp +++ b/test/test_mutex.cpp @@ -15,7 +15,7 @@ #include #define DEFAULT_EXECUTION_MONITOR_TYPE execution_monitor::use_sleep_only -#include +#include "./util.inl" template struct test_lock diff --git a/test/test_shared_mutex.cpp b/test/test_shared_mutex.cpp index 00c64274..c6069bb0 100644 --- a/test/test_shared_mutex.cpp +++ b/test/test_shared_mutex.cpp @@ -6,8 +6,8 @@ #include #include #include -#include -#include +#include "./util.inl" +#include "./shared_mutex_locking_thread.hpp" #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 ee8b4015..ac48d015 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 -#include +#include "./util.inl" +#include "./shared_mutex_locking_thread.hpp" #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 f341e0a0..e379aa08 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 -#include +#include "./util.inl" +#include "./shared_mutex_locking_thread.hpp" #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 847cd0be..2a981941 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 -#include +#include "./util.inl" +#include "./shared_mutex_locking_thread.hpp" #if defined BOOST_THREAD_USES_CHRONO diff --git a/test/test_thread.cpp b/test/test_thread.cpp index 5944a21e..b8a19f17 100644 --- a/test/test_thread.cpp +++ b/test/test_thread.cpp @@ -16,7 +16,7 @@ #include #define DEFAULT_EXECUTION_MONITOR_TYPE execution_monitor::use_sleep_only -#include +#include "./util.inl" int test_value; diff --git a/test/test_tss.cpp b/test/test_tss.cpp index 45a0cbd8..22f31c9c 100644 --- a/test/test_tss.cpp +++ b/test/test_tss.cpp @@ -13,7 +13,7 @@ #include -#include +#include "./util.inl" #include @@ -341,6 +341,18 @@ void test_tss_cleanup_not_called_for_null_pointer() BOOST_CHECK(!tss_cleanup_called); } +void test_tss_at_the_same_adress() +{ + for(int i=0; i<2; i++) + { + boost::thread_specific_ptr local_tss(tss_custom_cleanup); + local_tss.reset(new Dummy); + tss_cleanup_called=false; + BOOST_CHECK(tss_cleanup_called); + tss_cleanup_called=false; + BOOST_CHECK(!tss_cleanup_called); + } +} boost::unit_test::test_suite* init_unit_test_suite(int, char*[]) diff --git a/test/threads/thread/assign/copy_fail.cpp b/test/threads/thread/assign/copy_fail.cpp index 23a15b7c..e5e5f719 100644 --- a/test/threads/thread/assign/copy_fail.cpp +++ b/test/threads/thread/assign/copy_fail.cpp @@ -67,14 +67,4 @@ int main() } } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] - - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; - -} +#include "../../../remove_error_code_unused_warning.hpp" diff --git a/test/threads/thread/constr/copy_fail.cpp b/test/threads/thread/constr/copy_fail.cpp index 0b04b8c8..12534990 100644 --- a/test/threads/thread/constr/copy_fail.cpp +++ b/test/threads/thread/constr/copy_fail.cpp @@ -82,14 +82,5 @@ int main() } } -void remove_unused_warning() -{ - //../../../boost/system/error_code.hpp:214:36: warning: Ôboost::system::posix_categoryÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:215:36: warning: Ôboost::system::errno_ecatÕ defined but not used [-Wunused-variable] - //../../../boost/system/error_code.hpp:216:36: warning: Ôboost::system::native_ecatÕ defined but not used [-Wunused-variable] +#include "../../../remove_error_code_unused_warning.hpp" - (void)boost::system::posix_category; - (void)boost::system::errno_ecat; - (void)boost::system::native_ecat; - -} diff --git a/test/threads/thread/members/join_pass.cpp b/test/threads/thread/members/join_pass.cpp index 72977be0..35248d9e 100644 --- a/test/threads/thread/members/join_pass.cpp +++ b/test/threads/thread/members/join_pass.cpp @@ -53,7 +53,6 @@ public: void operator()() { BOOST_TEST(alive_ == 1); - std::cout << __FILE__ << ":" << __LINE__ <<" " << n_alive << std::endl; BOOST_TEST(n_alive == 1); op_run = true; } @@ -62,58 +61,73 @@ public: int G::n_alive = 0; bool G::op_run = false; -boost::thread* resource_deadlock_would_occur_th; +boost::thread* resource_deadlock_would_occur_th=0; boost::mutex resource_deadlock_would_occur_mtx; void resource_deadlock_would_occur_tester() { try { - std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl; boost::unique_lock lk(resource_deadlock_would_occur_mtx); - std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl; + resource_deadlock_would_occur_th->join(); - std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl; BOOST_TEST(false); - std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl; } catch (boost::system::system_error& e) { - std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl; BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur); } catch (...) { - std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl; BOOST_TEST(false&&"exception thrown"); } } +void throws_thread_resource_error_tester() +{ + { + try { + boost::throw_exception( + boost::thread_resource_error( + boost::system::errc::resource_deadlock_would_occur, + "boost thread: trying joining itself" + )); + BOOST_TEST(false); + } + catch (boost::system::system_error& e) + { + BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur); + } + catch (...) + { + BOOST_TEST(false&&"exception thrown"); + } + } +} + int main() { { - std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl; boost::thread t0( (G())); BOOST_TEST(t0.joinable()); t0.join(); BOOST_TEST(!t0.joinable()); } + { - std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl; - boost::unique_lock lk(resource_deadlock_would_occur_mtx); - std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl; - boost::thread t0( resource_deadlock_would_occur_tester ); - std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl; - resource_deadlock_would_occur_th = &t0; - std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl; - BOOST_TEST(t0.joinable()); - std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl; - lk.unlock(); - std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl; + boost::thread t0( throws_thread_resource_error_tester ); + t0.join(); + } + { + boost::unique_lock lk(resource_deadlock_would_occur_mtx); + boost::thread t0( resource_deadlock_would_occur_tester ); + resource_deadlock_would_occur_th = &t0; + BOOST_TEST(t0.joinable()); + lk.unlock(); + boost::this_thread::sleep_for(boost::chrono::milliseconds(100)); + boost::unique_lock lk2(resource_deadlock_would_occur_mtx); t0.join(); - std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl; BOOST_TEST(!t0.joinable()); - std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl; } // {