diff --git a/example/not_interleaved.cpp b/example/not_interleaved.cpp index b3ac3a66..49507a33 100644 --- a/example/not_interleaved.cpp +++ b/example/not_interleaved.cpp @@ -6,9 +6,10 @@ // adapted from the example given by Howard Hinnant in +#define BOOST_THREAD_VERSION 4 #include -#include +#include #include void use_cerr(boost::externally_locked_stream &mcerr) @@ -18,7 +19,18 @@ void use_cerr(boost::externally_locked_stream &mcerr) while (chrono::steady_clock::now() < tf) { mcerr << "logging data to cerr\n"; - this_thread::sleep_for(milliseconds(500)); + this_thread::sleep_for(chrono::milliseconds(500)); + } +} + +void use_cout(boost::externally_locked_stream &mcout) +{ + using namespace boost; + auto tf = chrono::steady_clock::now() + chrono::seconds(5); + while (chrono::steady_clock::now() < tf) + { + mcout << "logging data to cout\n"; + this_thread::sleep_for(chrono::milliseconds(250)); } } @@ -26,17 +38,20 @@ int main() { using namespace boost; - externally_locked_stream mcerr(std::cerr, terminal_mutex()); - externally_locked_stream mcout(std::cerr, terminal_mutex()); - externally_locked_stream mcin(std::cerr, terminal_mutex()); + recursive_mutex terminal_mutex; - thread t1(use_cerr, mcerr); - this_thread::sleep_for(boost::chrono::seconds(2)); + externally_locked_stream mcerr(std::cerr, terminal_mutex); + externally_locked_stream mcout(std::cout, terminal_mutex); + externally_locked_stream mcin(std::cin, terminal_mutex); + + scoped_thread<> t1(thread(use_cerr, boost::ref(mcerr))); + scoped_thread<> t2(thread(use_cout, boost::ref(mcout))); + this_thread::sleep_for(chrono::seconds(2)); std::string nm; mcout << "Enter name: "; - mcin >> nm; + //mcin >> nm; t1.join(); mcout << nm << '\n'; - return 0; + return 1; } diff --git a/include/boost/thread/detail/config.hpp b/include/boost/thread/detail/config.hpp index c5fa5c67..9db44382 100644 --- a/include/boost/thread/detail/config.hpp +++ b/include/boost/thread/detail/config.hpp @@ -66,6 +66,13 @@ #define BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS #endif + +#if defined BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX || defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#define BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST +//#elif defined __GNUC__ && (__GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ <= 6 )) +//#define BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST +#endif + /// BASIC_THREAD_ID // todo to be removed for 1.54 #if ! defined BOOST_THREAD_DONT_PROVIDE_BASIC_THREAD_ID \ diff --git a/include/boost/thread/detail/lockable_wrapper.hpp b/include/boost/thread/detail/lockable_wrapper.hpp index 71b6dfbf..8dc5a6cc 100644 --- a/include/boost/thread/detail/lockable_wrapper.hpp +++ b/include/boost/thread/detail/lockable_wrapper.hpp @@ -6,7 +6,9 @@ #ifndef BOOST_THREAD_DETAIL_LOCKABLE_WRAPPER_HPP #define BOOST_THREAD_DETAIL_LOCKABLE_WRAPPER_HPP -#if ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#include + +#if ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST #include #endif #include @@ -14,7 +16,7 @@ namespace boost { -#if ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#if ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST namespace thread_detail { template diff --git a/include/boost/thread/externally_locked_stream.hpp b/include/boost/thread/externally_locked_stream.hpp index 23f5cee4..38fbd544 100644 --- a/include/boost/thread/externally_locked_stream.hpp +++ b/include/boost/thread/externally_locked_stream.hpp @@ -4,12 +4,15 @@ // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_THREAD_EXTERNALLY_LOCKED_HPP -#define BOOST_THREAD_EXTERNALLY_LOCKED_HPP +#ifndef BOOST_THREAD_EXTERNALLY_LOCKED_STREAM_HPP +#define BOOST_THREAD_EXTERNALLY_LOCKED_STREAM_HPP #include +#include +#include #include +#include #include #include @@ -17,11 +20,11 @@ namespace boost { - static recursive_mutex& terminal_mutex() - { - static recursive-mutex mtx; - return mtx; - } + // inline static recursive_mutex& terminal_mutex() + // { + // static recursive_mutex mtx; + // return mtx; + // } template class externally_locked_stream; @@ -29,36 +32,47 @@ namespace boost template class stream_guard { - stream_guard(externally_locked_stream& mtx, adopt_lock_t) - : mtx_(mtx) + stream_guard(externally_locked_stream& mtx, adopt_lock_t) : + mtx_(mtx) { } - Stream& get() const - { - mtx_.get(*this); - } - friend class externally_locked_stream; + friend class externally_locked_stream ; public: typedef typename externally_locked_stream::mutex_type mutex_type; - BOOST_THREAD_NO_COPYABLE( externally_locked_stream ) + BOOST_THREAD_MOVABLE_ONLY( stream_guard) - stream_guard(externally_locked_stream& mtx) - : mtx_(mtx) + stream_guard(externally_locked_stream& mtx) : + mtx_(&mtx) { mtx.lock(); } - ~stream_guard() + stream_guard(BOOST_THREAD_RV_REF(stream_guard) rhs) + : mtx_(rhs.mtx_) { - mtx_.unlock(); + rhs.mtx_= 0; } + ~stream_guard() + { + if (mtx_ != 0) mtx_->unlock(); + } + + bool owns_lock(mutex_type const* l) const BOOST_NOEXCEPT + { + return l == mtx_->mutex(); + } + + Stream& get() const + { + return mtx_->get(*this); + } private: - externally_locked_stream& mtx_; + externally_locked_stream* mtx_; }; template @@ -78,6 +92,8 @@ namespace boost { typedef externally_locked base_type; public: + BOOST_THREAD_NO_COPYABLE( externally_locked_stream) + /** * Effects: Constructs an externally locked object storing the cloaked reference object. */ @@ -86,60 +102,57 @@ namespace boost { } - stream_guard hold() { - return stream_guard(*this); + return stream_guard (*this); } }; -//] + //] template - const stream_guard& operator<<(const stream_guard& lck, T arg) + inline const stream_guard& operator<<(const stream_guard& lck, T arg) { - lck.get() << arg; - return lck; + lck.get() << arg; + return lck; } template - const stream_guard& operator<<(const stream_guard& lck, - Stream& (*arg)(Stream&)) + inline const stream_guard& operator<<(const stream_guard& lck, Stream& (*arg)(Stream&)) { - lck.get() << arg; - return lck; + lck.get() << arg; + return lck; } template - const stream_guard& operator>>(const stream_guard& lck, T& arg) + inline const stream_guard& operator>>(const stream_guard& lck, T& arg) { - lck.get() >> arg; - return lck; + lck.get() >> arg; + return lck; } template - stream_guard operator<<(externally_locked_stream& mtx, T arg) + inline stream_guard operator<<(externally_locked_stream& mtx, T arg) { - mtx.lock(); - mtx.get() << arg; - return stream_guard(mtx, adopt_lock); + stream_guard lk(mtx); + mtx.get(lk) << arg; + return boost::move(lk); } template - stream_guard operator<<(externally_locked_stream& mtx, - Stream& (*arg)(Stream&)) + inline stream_guard operator<<(externally_locked_stream& mtx, Stream& (*arg)(Stream&)) { - mtx.lock(); - mtx.get() << arg; - return stream_guard(mtx, adopt_lock); + stream_guard lk(mtx); + mtx.get(lk) << arg; + return boost::move(lk); } template - stream_guard operator>>(externally_locked_stream& mtx, T& arg) + inline stream_guard operator>>(externally_locked_stream& mtx, T& arg) { - mtx.lock(); - mtx.get() >> arg; - return stream_guard(mtx, adopt_lock); + stream_guard lk(mtx); + mtx.get(lk) >> arg; + return boost::move(lk); } } diff --git a/include/boost/thread/lock_factories.hpp b/include/boost/thread/lock_factories.hpp index 045589b6..d5c9c0e9 100644 --- a/include/boost/thread/lock_factories.hpp +++ b/include/boost/thread/lock_factories.hpp @@ -59,7 +59,7 @@ namespace boost ); } template - std::tuple, unique_lock, unique_lock > make_unique_locks(L1& m1, L2& m2, L2& m3) + std::tuple, unique_lock, unique_lock > make_unique_locks(L1& m1, L2& m2, L3& m3) { boost::lock(m1, m2, m3); return std::tuple,unique_lock,unique_lock >( diff --git a/include/boost/thread/lock_guard.hpp b/include/boost/thread/lock_guard.hpp index a3007a8e..f6bfd335 100644 --- a/include/boost/thread/lock_guard.hpp +++ b/include/boost/thread/lock_guard.hpp @@ -7,6 +7,7 @@ #ifndef BOOST_THREAD_LOCK_GUARD_HPP #define BOOST_THREAD_LOCK_GUARD_HPP +#include #include #include #include @@ -45,7 +46,7 @@ namespace boost #endif } -#if ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#if ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST lock_guard(std::initializer_list > l_) : m(*(const_cast*>(l_.begin())->m)) { @@ -68,7 +69,7 @@ namespace boost }; -#if ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#if ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST template lock_guard make_lock_guard(Lockable& mtx) { diff --git a/include/boost/thread/strict_lock.hpp b/include/boost/thread/strict_lock.hpp index b4909cfd..a3cb60d7 100644 --- a/include/boost/thread/strict_lock.hpp +++ b/include/boost/thread/strict_lock.hpp @@ -6,6 +6,7 @@ #ifndef BOOST_THREAD_STRICT_LOCK_HPP #define BOOST_THREAD_STRICT_LOCK_HPP +#include #include #include #include @@ -50,7 +51,7 @@ namespace boost } /*< locks on construction >*/ -#if ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#if ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST strict_lock(std::initializer_list > l_) : mtx_(*(const_cast*>(l_.begin())->m)) { @@ -148,7 +149,7 @@ namespace boost tmp_lk_ = move(lk); /*< Move ownership to temporary lk >*/ } -#if ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#if ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST nested_strict_lock(std::initializer_list > l_) : lk_(*(const_cast*>(l_.begin())->m)) { @@ -203,7 +204,7 @@ public: { }; -#if ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#if ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST template strict_lock make_strict_lock(Lockable& mtx) { diff --git a/test/sync/futures/async/async_pass.cpp b/test/sync/futures/async/async_pass.cpp index 25c7a1ae..1e6bc3ca 100644 --- a/test/sync/futures/async/async_pass.cpp +++ b/test/sync/futures/async/async_pass.cpp @@ -166,6 +166,7 @@ int main() BOOST_TEST(f.get() == 3); Clock::time_point t1 = Clock::now(); BOOST_TEST(t1 - t0 < ms(100)); + std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl; } catch (std::exception& ex) { std::cout << __FILE__ <<"["<<__LINE__<<"]"< // lock_guard make_lock_guard(Lockable &, adopt_lock_t); +#define BOOST_THREAD_VERSION 4 + #include #include #include @@ -32,7 +34,7 @@ typedef boost::chrono::nanoseconds ns; #endif boost::mutex m; -#if ! defined(BOOST_NO_CXX11_AUTO) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST void f() { @@ -63,7 +65,7 @@ void f() int main() { -#if ! defined(BOOST_NO_CXX11_AUTO) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST m.lock(); boost::thread t(f); #ifdef BOOST_THREAD_USES_CHRONO diff --git a/test/sync/mutual_exclusion/locks/lock_guard/make_lock_guard_pass.cpp b/test/sync/mutual_exclusion/locks/lock_guard/make_lock_guard_pass.cpp index 20328ca4..6163add9 100644 --- a/test/sync/mutual_exclusion/locks/lock_guard/make_lock_guard_pass.cpp +++ b/test/sync/mutual_exclusion/locks/lock_guard/make_lock_guard_pass.cpp @@ -18,10 +18,7 @@ // lock_guard make_lock_guard(Lockable &); #define BOOST_THREAD_VERSION 4 -#define BOOST_THREAD_USES_LOG -#define BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS -#include #include #include #include @@ -38,7 +35,7 @@ typedef boost::chrono::nanoseconds ns; boost::mutex m; -#if ! defined(BOOST_NO_CXX11_AUTO) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST && defined BOOST_THREAD_USES_CHRONO +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST && defined BOOST_THREAD_USES_CHRONO void f() { @@ -47,9 +44,7 @@ void f() { const auto&& lg = boost::make_lock_guard(m); (void)lg; t1 = Clock::now(); - BOOST_THREAD_TRACE; } - BOOST_THREAD_TRACE; ns d = t1 - t0 - ms(250); // This test is spurious as it depends on the time the thread system switches the threads BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms @@ -59,7 +54,7 @@ void f() int main() { -#if ! defined(BOOST_NO_CXX11_AUTO) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST { m.lock(); boost::thread t(f); diff --git a/test/sync/mutual_exclusion/locks/nested_strict_lock/make_nested_strict_lock_pass.cpp b/test/sync/mutual_exclusion/locks/nested_strict_lock/make_nested_strict_lock_pass.cpp index 834d52d2..4505eca2 100644 --- a/test/sync/mutual_exclusion/locks/nested_strict_lock/make_nested_strict_lock_pass.cpp +++ b/test/sync/mutual_exclusion/locks/nested_strict_lock/make_nested_strict_lock_pass.cpp @@ -9,10 +9,7 @@ // strict_lock make_strict_lock(Lockable &); #define BOOST_THREAD_VERSION 4 -#define BOOST_THREAD_USES_LOG -#define BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS -#include #include #include #include @@ -30,7 +27,7 @@ typedef boost::chrono::nanoseconds ns; boost::mutex m; -#if ! defined(BOOST_NO_CXX11_AUTO) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST && defined BOOST_THREAD_USES_CHRONO +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST && defined BOOST_THREAD_USES_CHRONO void f() { @@ -40,9 +37,7 @@ void f() { const auto&& nlg = boost::make_nested_strict_lock(lg); (void)nlg; t1 = Clock::now(); - BOOST_THREAD_TRACE; } - BOOST_THREAD_TRACE; ns d = t1 - t0 - ms(250); // This test is spurious as it depends on the time the thread system switches the threads BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms @@ -52,7 +47,7 @@ void f() int main() { -#if ! defined(BOOST_NO_CXX11_AUTO) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST { m.lock(); boost::thread t(f); diff --git a/test/sync/mutual_exclusion/locks/strict_lock/make_strict_lock_pass.cpp b/test/sync/mutual_exclusion/locks/strict_lock/make_strict_lock_pass.cpp index 1f4af5ee..d9482045 100644 --- a/test/sync/mutual_exclusion/locks/strict_lock/make_strict_lock_pass.cpp +++ b/test/sync/mutual_exclusion/locks/strict_lock/make_strict_lock_pass.cpp @@ -9,10 +9,7 @@ // strict_lock make_strict_lock(Lockable &); #define BOOST_THREAD_VERSION 4 -#define BOOST_THREAD_USES_LOG -#define BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS -#include #include #include #include @@ -29,7 +26,7 @@ typedef boost::chrono::nanoseconds ns; boost::mutex m; -#if ! defined(BOOST_NO_CXX11_AUTO) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST && defined BOOST_THREAD_USES_CHRONO +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST && defined BOOST_THREAD_USES_CHRONO void f() { @@ -38,9 +35,7 @@ void f() { const auto&& lg = boost::make_strict_lock(m); (void)lg; t1 = Clock::now(); - BOOST_THREAD_TRACE; } - BOOST_THREAD_TRACE; ns d = t1 - t0 - ms(250); // This test is spurious as it depends on the time the thread system switches the threads BOOST_TEST(d < ns(2500000)+ms(1000)); // within 2.5ms @@ -50,7 +45,7 @@ void f() int main() { -#if ! defined(BOOST_NO_CXX11_AUTO) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST { m.lock(); boost::thread t(f); diff --git a/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_adopt_lock_pass.cpp b/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_adopt_lock_pass.cpp index 1450e096..2f385ec8 100644 --- a/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_adopt_lock_pass.cpp +++ b/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_adopt_lock_pass.cpp @@ -8,27 +8,24 @@ // template class unique_lock; // unique_lock make_unique_lock(Mutex&, adopt_lock_t); +#define BOOST_THREAD_VERSION 4 + #include #include #include -#if ! defined(BOOST_NO_CXX11_AUTO) && ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST - int main() { boost::mutex m; m.lock(); - auto lk = boost::make_unique_lock(m, boost::adopt_lock); +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) + auto +#else + boost::unique_lock +#endif + lk = boost::make_unique_lock(m, boost::adopt_lock); BOOST_TEST(lk.mutex() == &m); BOOST_TEST(lk.owns_lock() == true); return boost::report_errors(); } - -#else -int main() -{ - return boost::report_errors(); -} -#endif - diff --git a/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_defer_lock_pass.cpp b/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_defer_lock_pass.cpp index 42dc94f9..b94d89c2 100644 --- a/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_defer_lock_pass.cpp +++ b/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_defer_lock_pass.cpp @@ -10,26 +10,24 @@ // unique_lock(mutex_type& m, adopt_lock_t); +#define BOOST_THREAD_VERSION 4 + #include #include #include -#if ! defined(BOOST_NO_CXX11_AUTO) && ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST int main() { boost::mutex m; m.lock(); - auto lk = boost::make_unique_lock(m, boost::defer_lock); +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) + auto +#else + boost::unique_lock +#endif + lk = boost::make_unique_lock(m, boost::defer_lock); BOOST_TEST(lk.mutex() == &m); BOOST_TEST(lk.owns_lock() == false); return boost::report_errors(); } - -#else -int main() -{ - return boost::report_errors(); -} -#endif - diff --git a/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_mutex_pass.cpp b/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_mutex_pass.cpp index 55ef855a..c5732827 100644 --- a/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_mutex_pass.cpp +++ b/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_mutex_pass.cpp @@ -8,12 +8,15 @@ // template // unique_lock make_unique_lock(Mutex&); +#define BOOST_THREAD_VERSION 4 + +#include #include #include #include #include -#if ! defined(BOOST_NO_CXX11_AUTO) && ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST +//#if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) boost::mutex m; @@ -33,7 +36,13 @@ void f() time_point t0 = Clock::now(); time_point t1; { - auto&& _ = boost::make_unique_lock(m); (void)_; +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) + auto +#else + boost::unique_lock +#endif + //&& + _ = boost::make_unique_lock(m); (void)_; t1 = Clock::now(); } ns d = t1 - t0 - ms(250); @@ -43,7 +52,13 @@ void f() //time_point t0 = Clock::now(); //time_point t1; { - auto _ = boost::make_unique_lock(m); (void)_; +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) + auto +#else + boost::unique_lock +#endif + //&& + _ = boost::make_unique_lock(m); (void)_; //t1 = Clock::now(); } //ns d = t1 - t0 - ms(250); @@ -65,10 +80,10 @@ int main() return boost::report_errors(); } -#else -int main() -{ - return boost::report_errors(); -} -#endif +//#else +//int main() +//{ +// return boost::report_errors(); +//} +//#endif diff --git a/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp b/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp index b5d7a1ab..ddc39be3 100644 --- a/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp +++ b/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp @@ -8,13 +8,14 @@ // template class unique_lock; // unique_lock make_unique_lock(Mutex&, try_to_lock_t); +#define BOOST_THREAD_VERSION 4 + + #include #include #include #include -#if ! defined(BOOST_NO_CXX11_AUTO) && ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST - boost::mutex m; #if defined BOOST_THREAD_USES_CHRONO @@ -31,20 +32,40 @@ void f() #if defined BOOST_THREAD_USES_CHRONO time_point t0 = Clock::now(); { - auto lk = boost::make_unique_lock(m, boost::try_to_lock); +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) + auto +#else + boost::unique_lock +#endif + lk = boost::make_unique_lock(m, boost::try_to_lock); BOOST_TEST(lk.owns_lock() == false); } { - auto lk = boost::make_unique_lock(m, boost::try_to_lock); +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) + auto +#else + boost::unique_lock +#endif + lk = boost::make_unique_lock(m, boost::try_to_lock); BOOST_TEST(lk.owns_lock() == false); } { - auto lk = boost::make_unique_lock(m, boost::try_to_lock); +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) + auto +#else + boost::unique_lock +#endif + lk = boost::make_unique_lock(m, boost::try_to_lock); BOOST_TEST(lk.owns_lock() == false); } while (true) { - auto lk = boost::make_unique_lock(m, boost::try_to_lock); +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) + auto +#else + boost::unique_lock +#endif + lk = boost::make_unique_lock(m, boost::try_to_lock); if (lk.owns_lock()) break; } time_point t1 = Clock::now(); @@ -68,7 +89,12 @@ void f() // } while (true) { - auto lk = boost::make_unique_lock(m, boost::try_to_lock); +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) + auto +#else + boost::unique_lock +#endif + lk = boost::make_unique_lock(m, boost::try_to_lock); if (lk.owns_lock()) break; } //time_point t1 = Clock::now(); @@ -91,11 +117,3 @@ int main() return boost::report_errors(); } - -#else -int main() -{ - return boost::report_errors(); -} -#endif - diff --git a/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_locks_mutex_pass.cpp b/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_locks_mutex_pass.cpp index d1944f5f..13da746e 100644 --- a/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_locks_mutex_pass.cpp +++ b/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_locks_mutex_pass.cpp @@ -8,12 +8,14 @@ // template // unique_lock make_unique_lock(Mutex&); +#define BOOST_THREAD_VERSION 4 + #include #include #include #include -#if ! defined(BOOST_NO_CXX11_AUTO) && defined BOOST_NO_CXX11_HDR_TUPLE && ! defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && ! defined BOOST_NO_CXX11_HDR_TUPLE && ! defined BOOST_NO_CXX11_RVALUE_REFERENCES boost::mutex m1; boost::mutex m2; @@ -36,7 +38,7 @@ void f() time_point t0 = Clock::now(); time_point t1; { - auto&& _ = boost::make_unique_locks(m1,m2,m3); + auto&& _ = boost::make_unique_locks(m1,m2,m3); (void)_; t1 = Clock::now(); } ns d = t1 - t0 - ms(250); @@ -46,7 +48,7 @@ void f() //time_point t0 = Clock::now(); //time_point t1; { - auto&& _ = boost::make_unique_locks(m1,m2,m3); + auto&& _ = boost::make_unique_locks(m1,m2,m3); (void)_; //t1 = Clock::now(); } //ns d = t1 - t0 - ms(250);