2
0
mirror of https://github.com/boostorg/thread.git synced 2026-02-20 15:12:11 +00:00

Thread: merge from trunk: 1.52

[SVN r80450]
This commit is contained in:
Vicente J. Botet Escriba
2012-09-08 14:59:26 +00:00
parent c4420d7591
commit 7bc8c437ab
105 changed files with 917 additions and 711 deletions

View File

@@ -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"

View File

@@ -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;
}

View File

@@ -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;
}
// {