Boost logo

Boost-Commit :

From: john_at_[hidden]
Date: 2007-11-17 13:41:29


Author: johnmaddock
Date: 2007-11-17 13:41:29 EST (Sat, 17 Nov 2007)
New Revision: 41172
URL: http://svn.boost.org/trac/boost/changeset/41172

Log:
Changed test to catch throw exceptions from thread creation.
Text files modified:
   trunk/libs/regex/test/static_mutex/static_mutex_test.cpp | 49 ++++++++++++++++++++++++++++++---------
   1 files changed, 37 insertions(+), 12 deletions(-)

Modified: trunk/libs/regex/test/static_mutex/static_mutex_test.cpp
==============================================================================
--- trunk/libs/regex/test/static_mutex/static_mutex_test.cpp (original)
+++ trunk/libs/regex/test/static_mutex/static_mutex_test.cpp 2007-11-17 13:41:29 EST (Sat, 17 Nov 2007)
@@ -163,19 +163,44 @@
 {
    BOOST_TEST(0 != &up1);
    
- boost::thread thrd1(&thread1_proc);
- boost::thread thrd2(&thread1_proc);
- boost::thread thrd3(&thread2_proc);
- boost::thread thrd4(&thread2_proc);
- boost::thread thrd5(&thread3_proc);
- boost::thread thrd6(&thread3_proc);
+ std::list<boost::shared_ptr<boost::thread> > threads;
+ for(int i = 0; i < 2; ++i)
+ {
+ try{
+ threads.push_back(boost::shared_ptr<boost::thread>(new boost::thread(&thread1_proc)));
+ }
+ catch(const std::exception& e)
+ {
+ std::cerr << "<note>Thread creation failed with message: " << e.what() << "</note>" << std::endl;
+ }
+ }
+ for(int i = 0; i < 2; ++i)
+ {
+ try{
+ threads.push_back(boost::shared_ptr<boost::thread>(new boost::thread(&thread2_proc)));
+ }
+ catch(const std::exception& e)
+ {
+ std::cerr << "<note>Thread creation failed with message: " << e.what() << "</note>" << std::endl;
+ }
+ }
+ for(int i = 0; i < 2; ++i)
+ {
+ try{
+ threads.push_back(boost::shared_ptr<boost::thread>(new boost::thread(&thread3_proc)));
+ }
+ catch(const std::exception& e)
+ {
+ std::cerr << "<note>Thread creation failed with message: " << e.what() << "</note>" << std::endl;
+ }
+ }
 
- thrd1.join();
- thrd2.join();
- thrd3.join();
- thrd4.join();
- thrd5.join();
- thrd6.join();
+ std::list<boost::shared_ptr<boost::thread> >::const_iterator a(threads.begin()), b(threads.end());
+ while(a != b)
+ {
+ (*a)->join();
+ ++a;
+ }
 
    return total_failures;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk