2
0
mirror of https://github.com/boostorg/thread.git synced 2026-02-21 03:22:10 +00:00

Thread: merge from trunk latest changes.

[SVN r82356]
This commit is contained in:
Vicente J. Botet Escriba
2013-01-04 18:40:49 +00:00
parent d07835908f
commit 67da33a182
17 changed files with 193 additions and 134 deletions

View File

@@ -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__<<"]"<<ex.what() << std::endl;
BOOST_TEST(false && "exception thrown");
@@ -216,6 +217,7 @@ int main()
BOOST_TEST(&f.get() == &i);
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__<<"]"<<ex.what() << std::endl;
BOOST_TEST(false && "exception thrown");
@@ -303,6 +305,7 @@ int main()
f.get();
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__<<"]"<<ex.what() << std::endl;
BOOST_TEST(false && "exception thrown");

View File

@@ -17,6 +17,8 @@
// template <class Lockable>
// lock_guard<Lockable> make_lock_guard(Lockable &, adopt_lock_t);
#define BOOST_THREAD_VERSION 4
#include <boost/thread/lock_guard.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
@@ -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

View File

@@ -18,10 +18,7 @@
// lock_guard<Lockable> make_lock_guard(Lockable &);
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_USES_LOG
#define BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS
#include <boost/thread/detail/log.hpp>
#include <boost/thread/lock_guard.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
@@ -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);

View File

@@ -9,10 +9,7 @@
// strict_lock<Lockable> make_strict_lock(Lockable &);
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_USES_LOG
#define BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS
#include <boost/thread/detail/log.hpp>
#include <boost/thread/lock_types.hpp>
#include <boost/thread/strict_lock.hpp>
#include <boost/thread/mutex.hpp>
@@ -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);

View File

@@ -9,10 +9,7 @@
// strict_lock<Lockable> make_strict_lock(Lockable &);
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_USES_LOG
#define BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS
#include <boost/thread/detail/log.hpp>
#include <boost/thread/strict_lock.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
@@ -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);

View File

@@ -8,27 +8,24 @@
// template <class Mutex> class unique_lock;
// unique_lock<Mutex> make_unique_lock(Mutex&, adopt_lock_t);
#define BOOST_THREAD_VERSION 4
#include <boost/thread/lock_factories.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/detail/lightweight_test.hpp>
#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<boost::mutex>
#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

View File

@@ -10,26 +10,24 @@
// unique_lock(mutex_type& m, adopt_lock_t);
#define BOOST_THREAD_VERSION 4
#include <boost/thread/lock_factories.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/detail/lightweight_test.hpp>
#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<boost::mutex>
#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

View File

@@ -8,12 +8,15 @@
// template <class Mutex>
// unique_lock<Mutex> make_unique_lock(Mutex&);
#define BOOST_THREAD_VERSION 4
#include <boost/thread/detail/config.hpp>
#include <boost/thread/lock_factories.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/detail/lightweight_test.hpp>
#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<boost::mutex>
#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<boost::mutex>
#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

View File

@@ -8,13 +8,14 @@
// template <class Mutex> class unique_lock;
// unique_lock<Mutex> make_unique_lock(Mutex&, try_to_lock_t);
#define BOOST_THREAD_VERSION 4
#include <boost/thread/lock_factories.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/detail/lightweight_test.hpp>
#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<boost::mutex>
#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<boost::mutex>
#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<boost::mutex>
#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<boost::mutex>
#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<boost::mutex>
#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

View File

@@ -8,12 +8,14 @@
// template <class Mutex>
// unique_lock<Mutex> make_unique_lock(Mutex&);
#define BOOST_THREAD_VERSION 4
#include <boost/thread/lock_factories.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/detail/lightweight_test.hpp>
#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);