mirror of
https://github.com/boostorg/thread.git
synced 2026-02-21 03:22:10 +00:00
Thread: merge from trunk: 1.52
[SVN r80450]
This commit is contained in:
@@ -44,7 +44,7 @@ project
|
||||
<toolset>clang:<cxxflags>-pedantic
|
||||
<toolset>clang:<cxxflags>-Wno-long-long
|
||||
<toolset>clang:<cxxflags>-ansi
|
||||
#<toolset>clang:<cxxflags>-fpermissive # doesn't work
|
||||
#<toolset>clang:<cxxflags>-fpermissive # doesn't work
|
||||
|
||||
<toolset>gcc-mingw-4.4.0:<cxxflags>-fdiagnostics-show-option
|
||||
<toolset>gcc-mingw-4.5.0:<cxxflags>-fdiagnostics-show-option
|
||||
@@ -80,13 +80,13 @@ rule thread-run ( sources )
|
||||
rule thread-test ( sources )
|
||||
{
|
||||
return
|
||||
[ run $(sources) ../build//boost_thread : : :
|
||||
<library>/boost/test//boost_unit_test_framework/<link>static
|
||||
[ run $(sources) ../build//boost_thread : : :
|
||||
<library>/boost/test//boost_unit_test_framework/<link>static
|
||||
]
|
||||
[ run $(sources) ../src/tss_null.cpp ../build//boost_thread/<link>static
|
||||
: : :
|
||||
<library>/boost/test//boost_unit_test_framework/<link>static
|
||||
: $(sources[1]:B)_lib
|
||||
: : :
|
||||
<library>/boost/test//boost_unit_test_framework/<link>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 ]
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
17
test/remove_error_code_unused_warning.hpp
Normal file
17
test/remove_error_code_unused_warning.hpp
Normal file
@@ -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 <boost/thread/thread.hpp>
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
// future<typename result_of<F(Args...)>::type>
|
||||
// async(launch policy, F&& f, Args&&... args);
|
||||
|
||||
#define BOOST_THREAD_VERSION 3
|
||||
|
||||
#include <boost/thread/future.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
@@ -51,17 +52,17 @@ void f2()
|
||||
boost::this_thread::sleep_for(ms(200));
|
||||
}
|
||||
|
||||
boost::interprocess::unique_ptr<int> f3(int i)
|
||||
boost::interprocess::unique_ptr<int, boost::default_delete<int> > f3(int i)
|
||||
{
|
||||
boost::this_thread::sleep_for(ms(200));
|
||||
return boost::interprocess::unique_ptr<int>(new int(i));
|
||||
return boost::interprocess::unique_ptr<int, boost::default_delete<int> >(new int(i));
|
||||
}
|
||||
|
||||
boost::interprocess::unique_ptr<int> f4(boost::interprocess::unique_ptr<int>&& p)
|
||||
{
|
||||
boost::this_thread::sleep_for(ms(200));
|
||||
return boost::move(p);
|
||||
}
|
||||
//boost::interprocess::unique_ptr<int, boost::default_delete<int> > f4(boost::interprocess::unique_ptr<int, boost::default_delete<int> >&& 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<int> 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<int> 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<int&> 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<int&> 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<int&> 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<void> 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<void> 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<void> 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<boost::interprocess::unique_ptr<int>> 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<boost::interprocess::unique_ptr<int, boost::default_delete<int> > > 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<boost::interprocess::unique_ptr<int>> f = boost::async(f4, boost::interprocess::unique_ptr<int>(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<boost::interprocess::unique_ptr<int, boost::default_delete<int> > > f = boost::async(f4, boost::interprocess::unique_ptr<int, boost::default_delete<int> >(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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <boost/thread/future.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
|
||||
#include <libs/thread/test/sync/futures/test_allocator.hpp>
|
||||
#include "../test_allocator.hpp"
|
||||
#endif
|
||||
|
||||
int main()
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <boost/thread/future.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
|
||||
#include <libs/thread/test/sync/futures/test_allocator.hpp>
|
||||
#include "../test_allocator.hpp"
|
||||
|
||||
double fct()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
|
||||
#include <libs/thread/test/sync/futures/test_allocator.hpp>
|
||||
#include "../test_allocator.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <boost/thread/future.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
|
||||
#include <libs/thread/test/sync/futures/test_allocator.hpp>
|
||||
#include "../test_allocator.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <boost/thread/future.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
|
||||
#include <libs/thread/test/sync/futures/test_allocator.hpp>
|
||||
#include "../test_allocator.hpp"
|
||||
#endif
|
||||
|
||||
boost::mutex m0;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <boost/thread/future.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
|
||||
#include <libs/thread/test/sync/futures/test_allocator.hpp>
|
||||
#include "../test_allocator.hpp"
|
||||
#endif
|
||||
|
||||
boost::mutex m;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
|
||||
#include <libs/thread/test/sync/futures/test_allocator.hpp>
|
||||
#include "../test_allocator.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -32,13 +32,5 @@ int main()
|
||||
boost::lock_guard<boost::mutex> 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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -32,13 +32,5 @@ int main()
|
||||
boost::shared_lock_guard<boost::shared_mutex> 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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -9,54 +9,54 @@
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
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*[])
|
||||
{
|
||||
|
||||
@@ -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 <boost/thread/shared_mutex.hpp>
|
||||
#include <boost/thread/locks.hpp>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#define DEFAULT_EXECUTION_MONITOR_TYPE execution_monitor::use_sleep_only
|
||||
#include <libs/thread/test/util.inl>
|
||||
#include "./util.inl"
|
||||
|
||||
int test_value;
|
||||
#ifdef PTHREAD_STACK_MIN
|
||||
|
||||
89
test/test_3628.cpp
Normal file
89
test/test_3628.cpp
Normal file
@@ -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 <boost/thread/thread.hpp>
|
||||
#include <boost/thread/condition.hpp>
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
boost::recursive_mutex theMutex;
|
||||
|
||||
typedef std::list<boost::condition*> 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 << "<Notifier " << j << endl;
|
||||
|
||||
unsigned int i = 0;
|
||||
for (Conditions::iterator it = theConditions.begin(); it != theConditions.end() && i < 2; ++it)
|
||||
{
|
||||
(*it)->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;
|
||||
}
|
||||
|
||||
72
test/test_3837.cpp
Normal file
72
test/test_3837.cpp
Normal file
@@ -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 <iostream>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
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<thread_specific_ptr<dummy_class_tracks_deletions> > optr;
|
||||
//struct X
|
||||
//{
|
||||
// thread_specific_ptr<int> 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();
|
||||
|
||||
}
|
||||
@@ -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 <boost/thread.hpp>
|
||||
|
||||
int calculate_the_answer_to_life_the_universe_and_everything()
|
||||
|
||||
@@ -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 <iostream>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
|
||||
@@ -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 <boost/thread/thread.hpp>
|
||||
#include <boost/thread/shared_mutex.hpp>
|
||||
|
||||
|
||||
@@ -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 <iostream>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 <iostream>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
|
||||
@@ -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 <boost/thread.hpp>
|
||||
|
||||
void run_thread() {
|
||||
|
||||
@@ -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 <iostream>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/date_time.hpp>
|
||||
|
||||
@@ -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 <boost/thread.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time_io.hpp>
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
@@ -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";
|
||||
|
||||
@@ -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 <boost/thread/shared_mutex.hpp>
|
||||
#include <boost/thread/locks.hpp>
|
||||
|
||||
|
||||
37
test/test_7160.cpp
Normal file
37
test/test_7160.cpp
Normal file
@@ -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 <iostream>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
39
test/test_7328.cpp
Normal file
39
test/test_7328.cpp
Normal file
@@ -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 <iostream>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
//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();
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <libs/thread/test/util.inl>
|
||||
#include "./util.inl"
|
||||
|
||||
struct condition_test_data
|
||||
{
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <libs/thread/test/util.inl>
|
||||
#include <libs/thread/test/condition_test_common.hpp>
|
||||
#include "./util.inl"
|
||||
#include "./condition_test_common.hpp"
|
||||
|
||||
unsigned const number_of_test_threads=5;
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <libs/thread/test/util.inl>
|
||||
#include <libs/thread/test/condition_test_common.hpp>
|
||||
#include "./util.inl"
|
||||
#include "./condition_test_common.hpp"
|
||||
|
||||
void do_test_condition_notify_one_wakes_from_wait()
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <boost/thread/thread.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <libs/thread/test/util.inl>
|
||||
#include "./util.inl"
|
||||
|
||||
bool fake_predicate()
|
||||
{
|
||||
|
||||
@@ -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 <boost/config.hpp>
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#define DEFAULT_EXECUTION_MONITOR_TYPE execution_monitor::use_sleep_only
|
||||
#include <libs/thread/test/util.inl>
|
||||
#include "./util.inl"
|
||||
|
||||
template <typename M>
|
||||
struct test_lock
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/thread/xtime.hpp>
|
||||
#include <libs/thread/test/util.inl>
|
||||
#include <libs/thread/test/shared_mutex_locking_thread.hpp>
|
||||
#include "./util.inl"
|
||||
#include "./shared_mutex_locking_thread.hpp"
|
||||
|
||||
#define CHECK_LOCKED_VALUE_EQUAL(mutex_name,value,expected_value) \
|
||||
{ \
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/thread/xtime.hpp>
|
||||
#include <libs/thread/test/util.inl>
|
||||
#include <libs/thread/test/shared_mutex_locking_thread.hpp>
|
||||
#include "./util.inl"
|
||||
#include "./shared_mutex_locking_thread.hpp"
|
||||
|
||||
#define CHECK_LOCKED_VALUE_EQUAL(mutex_name,value,expected_value) \
|
||||
{ \
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/thread/xtime.hpp>
|
||||
#include <libs/thread/test/util.inl>
|
||||
#include <libs/thread/test/shared_mutex_locking_thread.hpp>
|
||||
#include "./util.inl"
|
||||
#include "./shared_mutex_locking_thread.hpp"
|
||||
|
||||
#define CHECK_LOCKED_VALUE_EQUAL(mutex_name,value,expected_value) \
|
||||
{ \
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/thread/shared_mutex.hpp>
|
||||
#include <libs/thread/test/util.inl>
|
||||
#include <libs/thread/test/shared_mutex_locking_thread.hpp>
|
||||
#include "./util.inl"
|
||||
#include "./shared_mutex_locking_thread.hpp"
|
||||
|
||||
#if defined BOOST_THREAD_USES_CHRONO
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#define DEFAULT_EXECUTION_MONITOR_TYPE execution_monitor::use_sleep_only
|
||||
#include <libs/thread/test/util.inl>
|
||||
#include "./util.inl"
|
||||
|
||||
int test_value;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <libs/thread/test/util.inl>
|
||||
#include "./util.inl"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -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<Dummy> 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*[])
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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<boost::mutex> 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<boost::mutex> 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<boost::mutex> 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<boost::mutex> lk2(resource_deadlock_would_occur_mtx);
|
||||
t0.join();
|
||||
std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl;
|
||||
BOOST_TEST(!t0.joinable());
|
||||
std::cout << __FILE__ << ":" << __LINE__ <<" " << std::endl;
|
||||
}
|
||||
|
||||
// {
|
||||
|
||||
Reference in New Issue
Block a user