|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r80544 - in trunk: boost/thread/detail boost/thread/pthread libs/thread/src/pthread libs/thread/test
From: vicente.botet_at_[hidden]
Date: 2012-09-16 14:50:18
Author: viboes
Date: 2012-09-16 14:50:17 EDT (Sun, 16 Sep 2012)
New Revision: 80544
URL: http://svn.boost.org/trac/boost/changeset/80544
Log:
Thread: (posix) Make use of BOOST_TRY family macros
Text files modified:
trunk/boost/thread/detail/config.hpp | 5 +++++
trunk/boost/thread/pthread/once.hpp | 23 ++++++++++-------------
trunk/libs/thread/src/pthread/thread.cpp | 11 ++++-------
trunk/libs/thread/test/test_4882.cpp | 14 ++++++++------
4 files changed, 27 insertions(+), 26 deletions(-)
Modified: trunk/boost/thread/detail/config.hpp
==============================================================================
--- trunk/boost/thread/detail/config.hpp (original)
+++ trunk/boost/thread/detail/config.hpp 2012-09-16 14:50:17 EDT (Sun, 16 Sep 2012)
@@ -8,6 +8,11 @@
#ifndef BOOST_THREAD_CONFIG_WEK01032003_HPP
#define BOOST_THREAD_CONFIG_WEK01032003_HPP
+// Force SIG_ATOMIC_MAX to be defined
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS
+#endif
+
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
Modified: trunk/boost/thread/pthread/once.hpp
==============================================================================
--- trunk/boost/thread/pthread/once.hpp (original)
+++ trunk/boost/thread/pthread/once.hpp 2012-09-16 14:50:17 EDT (Sun, 16 Sep 2012)
@@ -12,17 +12,17 @@
#include <boost/thread/detail/config.hpp>
-#include <pthread.h>
-#include <boost/assert.hpp>
#include <boost/thread/pthread/pthread_mutex_scoped_lock.hpp>
-#include <boost/cstdint.hpp>
#include <boost/thread/detail/delete.hpp>
-// Force SIG_ATOMIC_MAX tobe defined
-#define __STDC_LIMIT_MACROS
-#include <csignal>
+#include <boost/detail/no_exceptions_support.hpp>
+#include <boost/assert.hpp>
#include <boost/config/abi_prefix.hpp>
+#include <boost/cstdint.hpp>
+#include <pthread.h>
+#include <csignal>
+
namespace boost
{
@@ -92,21 +92,18 @@
if(flag.epoch==uninitialized_flag)
{
flag.epoch=being_initialized;
-#ifndef BOOST_NO_EXCEPTIONS
- try // BOOST_NO_EXCEPTIONS protected
+ BOOST_TRY
{
-#endif
pthread::pthread_mutex_scoped_unlock relocker(&detail::once_epoch_mutex);
f();
-#ifndef BOOST_NO_EXCEPTIONS
}
- catch(...) // BOOST_NO_EXCEPTIONS protected
+ BOOST_CATCH (...)
{
flag.epoch=uninitialized_flag;
BOOST_VERIFY(!pthread_cond_broadcast(&detail::once_epoch_cv));
- throw; // BOOST_NO_EXCEPTIONS protected
+ BOOST_RETHROW
}
-#endif
+ BOOST_CATCH_END
flag.epoch=--detail::once_global_epoch;
BOOST_VERIFY(!pthread_cond_broadcast(&detail::once_epoch_cv));
}
Modified: trunk/libs/thread/src/pthread/thread.cpp
==============================================================================
--- trunk/libs/thread/src/pthread/thread.cpp (original)
+++ trunk/libs/thread/src/pthread/thread.cpp 2012-09-16 14:50:17 EDT (Sun, 16 Sep 2012)
@@ -148,20 +148,17 @@
boost::detail::thread_data_ptr thread_info = static_cast<boost::detail::thread_data_base*>(param)->self;
thread_info->self.reset();
detail::set_current_thread_data(thread_info.get());
-#ifndef BOOST_NO_EXCEPTIONS
- try // BOOST_NO_EXCEPTIONS protected
-#endif
+ BOOST_TRY
{
thread_info->run();
}
-#ifndef BOOST_NO_EXCEPTIONS
- catch(thread_interrupted const&) // BOOST_NO_EXCEPTIONS protected
+ BOOST_CATCH (thread_interrupted const&)
{
}
-#endif
+ BOOST_CATCH_END
// Removed as it stops the debugger identifying the cause of the exception
// Unhandled exceptions still cause the application to terminate
-// catch(...) // BOOST_NO_EXCEPTIONS protected
+// BOOST_CATCH(...)
// {
// std::terminate();
// }
Modified: trunk/libs/thread/test/test_4882.cpp
==============================================================================
--- trunk/libs/thread/test/test_4882.cpp (original)
+++ trunk/libs/thread/test/test_4882.cpp 2012-09-16 14:50:17 EDT (Sun, 16 Sep 2012)
@@ -5,6 +5,7 @@
#include <boost/thread/thread.hpp>
#include <boost/thread/shared_mutex.hpp>
+#include <boost/detail/no_exceptions_support.hpp>
#include <iostream>
@@ -13,9 +14,7 @@
void thread()
{
std::cout << __FILE__ << ":" << __LINE__ << std::endl;
-#ifndef BOOST_NO_EXCEPTIONS
- try
-#endif
+ BOOST_TRY
{
for (int i =0; i<10; ++i)
{
@@ -30,12 +29,15 @@
}
}
}
-#ifndef BOOST_NO_EXCEPTIONS
- catch (boost::lock_error& le)
+ BOOST_CATCH (boost::lock_error& le)
{
std::cerr << "lock_error exception\n";
}
-#endif
+ BOOST_CATCH (...)
+ {
+ std::cerr << " exception\n";
+ }
+ BOOST_CATCH_END
std::cout << __FILE__ << ":" << __LINE__ << std::endl;
}
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