|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57912 - in trunk: boost/thread boost/thread/pthread boost/thread/win32 libs/thread/src/pthread libs/thread/src/win32
From: anthony_at_[hidden]
Date: 2009-11-24 16:49:30
Author: anthonyw
Date: 2009-11-24 16:49:27 EST (Tue, 24 Nov 2009)
New Revision: 57912
URL: http://svn.boost.org/trac/boost/changeset/57912
Log:
A partial fix for issue #2100: use boost::throw_exception for all exceptions except thread_interrupted
Text files modified:
trunk/boost/thread/barrier.hpp | 3 ++-
trunk/boost/thread/future.hpp | 35 ++++++++++++++++++-----------------
trunk/boost/thread/locks.hpp | 22 +++++++++++-----------
trunk/boost/thread/pthread/condition_variable.hpp | 8 ++++----
trunk/boost/thread/pthread/condition_variable_fwd.hpp | 3 ++-
trunk/boost/thread/pthread/mutex.hpp | 7 ++++---
trunk/boost/thread/pthread/once.hpp | 5 +++++
trunk/boost/thread/pthread/recursive_mutex.hpp | 17 +++++++++--------
trunk/boost/thread/win32/thread_heap_alloc.hpp | 3 ++-
trunk/boost/thread/win32/thread_primitives.hpp | 7 ++++---
trunk/libs/thread/src/pthread/thread.cpp | 3 ++-
trunk/libs/thread/src/win32/thread.cpp | 3 ++-
12 files changed, 65 insertions(+), 51 deletions(-)
Modified: trunk/boost/thread/barrier.hpp
==============================================================================
--- trunk/boost/thread/barrier.hpp (original)
+++ trunk/boost/thread/barrier.hpp 2009-11-24 16:49:27 EST (Tue, 24 Nov 2009)
@@ -9,6 +9,7 @@
#define BOOST_BARRIER_JDM030602_HPP
#include <boost/thread/detail/config.hpp>
+#include <boost/throw_exception.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
@@ -27,7 +28,7 @@
: m_threshold(count), m_count(count), m_generation(0)
{
if (count == 0)
- throw std::invalid_argument("count cannot be zero.");
+ boost::throw_exception(std::invalid_argument("count cannot be zero."));
}
bool wait()
Modified: trunk/boost/thread/future.hpp
==============================================================================
--- trunk/boost/thread/future.hpp (original)
+++ trunk/boost/thread/future.hpp 2009-11-24 16:49:27 EST (Tue, 24 Nov 2009)
@@ -16,6 +16,7 @@
#include <boost/type_traits/is_convertible.hpp>
#include <boost/mpl/if.hpp>
#include <boost/config.hpp>
+#include <boost/throw_exception.hpp>
#include <algorithm>
#include <boost/function.hpp>
#include <boost/bind.hpp>
@@ -673,7 +674,7 @@
{
if(!future)
{
- throw future_uninitialized();
+ boost::throw_exception(future_uninitialized());
}
return future->get();
@@ -709,7 +710,7 @@
{
if(!future)
{
- throw future_uninitialized();
+ boost::throw_exception(future_uninitialized());
}
future->wait(false);
}
@@ -724,7 +725,7 @@
{
if(!future)
{
- throw future_uninitialized();
+ boost::throw_exception(future_uninitialized());
}
return future->timed_wait_until(abs_time);
}
@@ -830,7 +831,7 @@
{
if(!future)
{
- throw future_uninitialized();
+ boost::throw_exception(future_uninitialized());
}
return future->get();
@@ -866,7 +867,7 @@
{
if(!future)
{
- throw future_uninitialized();
+ boost::throw_exception(future_uninitialized());
}
future->wait(false);
}
@@ -881,7 +882,7 @@
{
if(!future)
{
- throw future_uninitialized();
+ boost::throw_exception(future_uninitialized());
}
return future->timed_wait_until(abs_time);
}
@@ -974,7 +975,7 @@
lazy_init();
if(future_obtained)
{
- throw future_already_retrieved();
+ boost::throw_exception(future_already_retrieved());
}
future_obtained=true;
return unique_future<R>(future);
@@ -986,7 +987,7 @@
boost::lock_guard<boost::mutex> lock(future->mutex);
if(future->done)
{
- throw promise_already_satisfied();
+ boost::throw_exception(promise_already_satisfied());
}
future->mark_finished_with_result_internal(r);
}
@@ -998,7 +999,7 @@
boost::lock_guard<boost::mutex> lock(future->mutex);
if(future->done)
{
- throw promise_already_satisfied();
+ boost::throw_exception(promise_already_satisfied());
}
future->mark_finished_with_result_internal(static_cast<typename detail::future_traits<R>::rvalue_source_type>(r));
}
@@ -1009,7 +1010,7 @@
boost::lock_guard<boost::mutex> lock(future->mutex);
if(future->done)
{
- throw promise_already_satisfied();
+ boost::throw_exception(promise_already_satisfied());
}
future->mark_exceptional_finish_internal(p);
}
@@ -1109,7 +1110,7 @@
if(future_obtained)
{
- throw future_already_retrieved();
+ boost::throw_exception(future_already_retrieved());
}
future_obtained=true;
return unique_future<void>(future);
@@ -1121,7 +1122,7 @@
boost::lock_guard<boost::mutex> lock(future->mutex);
if(future->done)
{
- throw promise_already_satisfied();
+ boost::throw_exception(promise_already_satisfied());
}
future->mark_finished_with_result_internal();
}
@@ -1132,7 +1133,7 @@
boost::lock_guard<boost::mutex> lock(future->mutex);
if(future->done)
{
- throw promise_already_satisfied();
+ boost::throw_exception(promise_already_satisfied());
}
future->mark_exceptional_finish_internal(p);
}
@@ -1164,7 +1165,7 @@
boost::lock_guard<boost::mutex> lk(this->mutex);
if(started)
{
- throw task_already_started();
+ boost::throw_exception(task_already_started());
}
started=true;
}
@@ -1326,7 +1327,7 @@
{
if(!task)
{
- throw task_moved();
+ boost::throw_exception(task_moved());
}
else if(!future_obtained)
{
@@ -1335,7 +1336,7 @@
}
else
{
- throw future_already_retrieved();
+ boost::throw_exception(future_already_retrieved());
}
}
@@ -1345,7 +1346,7 @@
{
if(!task)
{
- throw task_moved();
+ boost::throw_exception(task_moved());
}
task->run();
}
Modified: trunk/boost/thread/locks.hpp
==============================================================================
--- trunk/boost/thread/locks.hpp (original)
+++ trunk/boost/thread/locks.hpp 2009-11-24 16:49:27 EST (Tue, 24 Nov 2009)
@@ -344,7 +344,7 @@
{
if(owns_lock())
{
- throw boost::lock_error();
+ boost::throw_exception(boost::lock_error());
}
m->lock();
is_locked=true;
@@ -353,7 +353,7 @@
{
if(owns_lock())
{
- throw boost::lock_error();
+ boost::throw_exception(boost::lock_error());
}
is_locked=m->try_lock();
return is_locked;
@@ -379,7 +379,7 @@
{
if(!owns_lock())
{
- throw boost::lock_error();
+ boost::throw_exception(boost::lock_error());
}
m->unlock();
is_locked=false;
@@ -570,7 +570,7 @@
{
if(owns_lock())
{
- throw boost::lock_error();
+ boost::throw_exception(boost::lock_error());
}
m->lock_shared();
is_locked=true;
@@ -579,7 +579,7 @@
{
if(owns_lock())
{
- throw boost::lock_error();
+ boost::throw_exception(boost::lock_error());
}
is_locked=m->try_lock_shared();
return is_locked;
@@ -588,7 +588,7 @@
{
if(owns_lock())
{
- throw boost::lock_error();
+ boost::throw_exception(boost::lock_error());
}
is_locked=m->timed_lock_shared(target_time);
return is_locked;
@@ -598,7 +598,7 @@
{
if(owns_lock())
{
- throw boost::lock_error();
+ boost::throw_exception(boost::lock_error());
}
is_locked=m->timed_lock_shared(target_time);
return is_locked;
@@ -607,7 +607,7 @@
{
if(!owns_lock())
{
- throw boost::lock_error();
+ boost::throw_exception(boost::lock_error());
}
m->unlock_shared();
is_locked=false;
@@ -733,7 +733,7 @@
{
if(owns_lock())
{
- throw boost::lock_error();
+ boost::throw_exception(boost::lock_error());
}
m->lock_upgrade();
is_locked=true;
@@ -742,7 +742,7 @@
{
if(owns_lock())
{
- throw boost::lock_error();
+ boost::throw_exception(boost::lock_error());
}
is_locked=m->try_lock_upgrade();
return is_locked;
@@ -751,7 +751,7 @@
{
if(!owns_lock())
{
- throw boost::lock_error();
+ boost::throw_exception(boost::lock_error());
}
m->unlock_upgrade();
is_locked=false;
Modified: trunk/boost/thread/pthread/condition_variable.hpp
==============================================================================
--- trunk/boost/thread/pthread/condition_variable.hpp (original)
+++ trunk/boost/thread/pthread/condition_variable.hpp 2009-11-24 16:49:27 EST (Tue, 24 Nov 2009)
@@ -57,13 +57,13 @@
int const res=pthread_mutex_init(&internal_mutex,NULL);
if(res)
{
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
int const res2=pthread_cond_init(&cond,NULL);
if(res2)
{
BOOST_VERIFY(!pthread_mutex_destroy(&internal_mutex));
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
}
~condition_variable_any()
@@ -87,7 +87,7 @@
}
if(res)
{
- throw condition_error();
+ boost::throw_exception(condition_error());
}
}
@@ -117,7 +117,7 @@
}
if(res)
{
- throw condition_error();
+ boost::throw_exception(condition_error());
}
return true;
}
Modified: trunk/boost/thread/pthread/condition_variable_fwd.hpp
==============================================================================
--- trunk/boost/thread/pthread/condition_variable_fwd.hpp (original)
+++ trunk/boost/thread/pthread/condition_variable_fwd.hpp 2009-11-24 16:49:27 EST (Tue, 24 Nov 2009)
@@ -6,6 +6,7 @@
// (C) Copyright 2007-8 Anthony Williams
#include <boost/assert.hpp>
+#include <boost/throw_exception.hpp>
#include <pthread.h>
#include <boost/thread/mutex.hpp>
#include <boost/thread/locks.hpp>
@@ -30,7 +31,7 @@
int const res=pthread_cond_init(&cond,NULL);
if(res)
{
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
}
~condition_variable()
Modified: trunk/boost/thread/pthread/mutex.hpp
==============================================================================
--- trunk/boost/thread/pthread/mutex.hpp (original)
+++ trunk/boost/thread/pthread/mutex.hpp 2009-11-24 16:49:27 EST (Tue, 24 Nov 2009)
@@ -7,6 +7,7 @@
#include <pthread.h>
#include <boost/utility.hpp>
+#include <boost/throw_exception.hpp>
#include <boost/thread/exceptions.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/thread_time.hpp>
@@ -37,7 +38,7 @@
int const res=pthread_mutex_init(&m,NULL);
if(res)
{
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
}
~mutex()
@@ -89,14 +90,14 @@
int const res=pthread_mutex_init(&m,NULL);
if(res)
{
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
#ifndef BOOST_PTHREAD_HAS_TIMEDLOCK
int const res2=pthread_cond_init(&cond,NULL);
if(res2)
{
BOOST_VERIFY(!pthread_mutex_destroy(&m));
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
is_locked=false;
#endif
Modified: trunk/boost/thread/pthread/once.hpp
==============================================================================
--- trunk/boost/thread/pthread/once.hpp (original)
+++ trunk/boost/thread/pthread/once.hpp 2009-11-24 16:49:27 EST (Tue, 24 Nov 2009)
@@ -10,6 +10,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/thread/detail/config.hpp>
+#include <boost/config.hpp>
#include <pthread.h>
#include <boost/assert.hpp>
@@ -58,10 +59,13 @@
if(flag.epoch==uninitialized_flag)
{
flag.epoch=being_initialized;
+#ifndef BOOST_NO_EXCEPTIONS
try
{
+#endif
pthread::pthread_mutex_scoped_unlock relocker(&detail::once_epoch_mutex);
f();
+#ifndef BOOST_NO_EXCEPTIONS
}
catch(...)
{
@@ -69,6 +73,7 @@
BOOST_VERIFY(!pthread_cond_broadcast(&detail::once_epoch_cv));
throw;
}
+#endif
flag.epoch=--detail::once_global_epoch;
BOOST_VERIFY(!pthread_cond_broadcast(&detail::once_epoch_cv));
}
Modified: trunk/boost/thread/pthread/recursive_mutex.hpp
==============================================================================
--- trunk/boost/thread/pthread/recursive_mutex.hpp (original)
+++ trunk/boost/thread/pthread/recursive_mutex.hpp 2009-11-24 16:49:27 EST (Tue, 24 Nov 2009)
@@ -7,6 +7,7 @@
#include <pthread.h>
#include <boost/utility.hpp>
+#include <boost/throw_exception.hpp>
#include <boost/thread/exceptions.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/thread_time.hpp>
@@ -42,18 +43,18 @@
int const init_attr_res=pthread_mutexattr_init(&attr);
if(init_attr_res)
{
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
int const set_attr_res=pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE);
if(set_attr_res)
{
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
int const res=pthread_mutex_init(&m,&attr);
if(res)
{
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
BOOST_VERIFY(!pthread_mutexattr_destroy(&attr));
}
@@ -111,32 +112,32 @@
int const init_attr_res=pthread_mutexattr_init(&attr);
if(init_attr_res)
{
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
int const set_attr_res=pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE);
if(set_attr_res)
{
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
int const res=pthread_mutex_init(&m,&attr);
if(res)
{
BOOST_VERIFY(!pthread_mutexattr_destroy(&attr));
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
BOOST_VERIFY(!pthread_mutexattr_destroy(&attr));
#else
int const res=pthread_mutex_init(&m,NULL);
if(res)
{
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
int const res2=pthread_cond_init(&cond,NULL);
if(res2)
{
BOOST_VERIFY(!pthread_mutex_destroy(&m));
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
is_locked=false;
count=0;
Modified: trunk/boost/thread/win32/thread_heap_alloc.hpp
==============================================================================
--- trunk/boost/thread/win32/thread_heap_alloc.hpp (original)
+++ trunk/boost/thread/win32/thread_heap_alloc.hpp 2009-11-24 16:49:27 EST (Tue, 24 Nov 2009)
@@ -8,6 +8,7 @@
#include "thread_primitives.hpp"
#include <stdexcept>
#include <boost/assert.hpp>
+#include <boost/throw_exception.hpp>
#if defined( BOOST_USE_WINDOWS_H )
# include <windows.h>
@@ -60,7 +61,7 @@
void* const heap_memory=detail::win32::HeapAlloc(detail::win32::GetProcessHeap(),0,size);
if(!heap_memory)
{
- throw std::bad_alloc();
+ boost::throw_exception(std::bad_alloc());
}
return heap_memory;
}
Modified: trunk/boost/thread/win32/thread_primitives.hpp
==============================================================================
--- trunk/boost/thread/win32/thread_primitives.hpp (original)
+++ trunk/boost/thread/win32/thread_primitives.hpp 2009-11-24 16:49:27 EST (Tue, 24 Nov 2009)
@@ -11,6 +11,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
+#include <boost/throw_exception.hpp>
#include <boost/assert.hpp>
#include <boost/thread/exceptions.hpp>
#include <boost/detail/interlocked.hpp>
@@ -177,7 +178,7 @@
#endif
if(!res)
{
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
return res;
}
@@ -191,7 +192,7 @@
#endif
if(!res)
{
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
return res;
}
@@ -204,7 +205,7 @@
bool const success=DuplicateHandle(current_process,source,current_process,&new_handle,0,false,same_access_flag)!=0;
if(!success)
{
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
return new_handle;
}
Modified: trunk/libs/thread/src/pthread/thread.cpp
==============================================================================
--- trunk/libs/thread/src/pthread/thread.cpp (original)
+++ trunk/libs/thread/src/pthread/thread.cpp 2009-11-24 16:49:27 EST (Tue, 24 Nov 2009)
@@ -13,6 +13,7 @@
#include <boost/thread/locks.hpp>
#include <boost/thread/once.hpp>
#include <boost/thread/tss.hpp>
+#include <boost/throw_exception.hpp>
#ifdef __linux__
#include <sys/sysinfo.h>
#elif defined(__APPLE__) || defined(__FreeBSD__)
@@ -186,7 +187,7 @@
if (res != 0)
{
thread_info->self.reset();
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
}
Modified: trunk/libs/thread/src/win32/thread.cpp
==============================================================================
--- trunk/libs/thread/src/win32/thread.cpp (original)
+++ trunk/libs/thread/src/win32/thread.cpp 2009-11-24 16:49:27 EST (Tue, 24 Nov 2009)
@@ -17,6 +17,7 @@
#include <boost/thread/once.hpp>
#include <boost/thread/tss.hpp>
#include <boost/assert.hpp>
+#include <boost/throw_exception.hpp>
#include <boost/thread/detail/tss_hooks.hpp>
#include <boost/date_time/posix_time/conversion.hpp>
@@ -188,7 +189,7 @@
uintptr_t const new_thread=_beginthreadex(0,0,&thread_start_function,thread_info.get(),CREATE_SUSPENDED,&thread_info->id);
if(!new_thread)
{
- throw thread_resource_error();
+ boost::throw_exception(thread_resource_error());
}
intrusive_ptr_add_ref(thread_info.get());
thread_info->thread_handle=(detail::win32::handle)(new_thread);
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