mirror of
https://github.com/boostorg/thread.git
synced 2026-01-23 06:02:14 +00:00
Thread: cleanup no-exceptions on windows
[SVN r79383]
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
#define BOOST_THREAD_FUTURE_HPP
|
||||
|
||||
#include <boost/thread/detail/config.hpp>
|
||||
|
||||
// boost::thread::future requires exception handling
|
||||
// due to boost::exception::exception_ptr dependency
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
|
||||
#include <boost/detail/scoped_enum_emulation.hpp>
|
||||
@@ -54,9 +58,6 @@
|
||||
#define BOOST_THREAD_FUTURE unique_future
|
||||
#endif
|
||||
|
||||
// boost::thread::future requires exception handling
|
||||
// due to boost::exception::exception_ptr dependency
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
@@ -157,7 +157,9 @@ namespace boost
|
||||
status=BOOST_INTERLOCKED_COMPARE_EXCHANGE(&flag.status,running_value,0);
|
||||
if(!status)
|
||||
{
|
||||
try
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try // BOOST_NO_EXCEPTIONS protected
|
||||
#endif
|
||||
{
|
||||
if(!event_handle)
|
||||
{
|
||||
@@ -185,7 +187,8 @@ namespace boost
|
||||
}
|
||||
break;
|
||||
}
|
||||
catch(...)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
catch(...) // BOOST_NO_EXCEPTIONS protected
|
||||
{
|
||||
BOOST_INTERLOCKED_EXCHANGE(&flag.status,0);
|
||||
if(!event_handle)
|
||||
@@ -196,8 +199,9 @@ namespace boost
|
||||
{
|
||||
::boost::detail::win32::SetEvent(event_handle);
|
||||
}
|
||||
throw;
|
||||
throw; // BOOST_NO_EXCEPTIONS protected
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if(!counted)
|
||||
|
||||
@@ -75,16 +75,20 @@ namespace boost
|
||||
inline T* heap_new()
|
||||
{
|
||||
void* const heap_memory=allocate_raw_heap_memory(sizeof(T));
|
||||
try
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try // BOOST_NO_EXCEPTIONS protected
|
||||
#endif
|
||||
{
|
||||
T* const data=new (heap_memory) T();
|
||||
return data;
|
||||
}
|
||||
catch(...)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
catch(...) // BOOST_NO_EXCEPTIONS protected
|
||||
{
|
||||
free_raw_heap_memory(heap_memory);
|
||||
throw;
|
||||
throw; // BOOST_NO_EXCEPTIONS protected
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
@@ -92,127 +96,159 @@ namespace boost
|
||||
inline T* heap_new(A1&& a1)
|
||||
{
|
||||
void* const heap_memory=allocate_raw_heap_memory(sizeof(T));
|
||||
try
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try // BOOST_NO_EXCEPTIONS protected
|
||||
#endif
|
||||
{
|
||||
T* const data=new (heap_memory) T(static_cast<A1&&>(a1));
|
||||
return data;
|
||||
}
|
||||
catch(...)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
catch(...) // BOOST_NO_EXCEPTIONS protected
|
||||
{
|
||||
free_raw_heap_memory(heap_memory);
|
||||
throw;
|
||||
throw; // BOOST_NO_EXCEPTIONS protected
|
||||
}
|
||||
#endif
|
||||
}
|
||||
template<typename T,typename A1,typename A2>
|
||||
inline T* heap_new(A1&& a1,A2&& a2)
|
||||
{
|
||||
void* const heap_memory=allocate_raw_heap_memory(sizeof(T));
|
||||
try
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try // BOOST_NO_EXCEPTIONS protected
|
||||
#endif
|
||||
{
|
||||
T* const data=new (heap_memory) T(static_cast<A1&&>(a1),static_cast<A2&&>(a2));
|
||||
return data;
|
||||
}
|
||||
catch(...)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
catch(...) // BOOST_NO_EXCEPTIONS protected
|
||||
{
|
||||
free_raw_heap_memory(heap_memory);
|
||||
throw;
|
||||
throw; // BOOST_NO_EXCEPTIONS protected
|
||||
}
|
||||
#endif
|
||||
}
|
||||
template<typename T,typename A1,typename A2,typename A3>
|
||||
inline T* heap_new(A1&& a1,A2&& a2,A3&& a3)
|
||||
{
|
||||
void* const heap_memory=allocate_raw_heap_memory(sizeof(T));
|
||||
try
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try // BOOST_NO_EXCEPTIONS protected
|
||||
#endif
|
||||
{
|
||||
T* const data=new (heap_memory) T(static_cast<A1&&>(a1),static_cast<A2&&>(a2),
|
||||
static_cast<A3&&>(a3));
|
||||
return data;
|
||||
}
|
||||
catch(...)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
catch(...) // BOOST_NO_EXCEPTIONS protected
|
||||
{
|
||||
free_raw_heap_memory(heap_memory);
|
||||
throw;
|
||||
throw; // BOOST_NO_EXCEPTIONS protected
|
||||
}
|
||||
#endif
|
||||
}
|
||||
template<typename T,typename A1,typename A2,typename A3,typename A4>
|
||||
inline T* heap_new(A1&& a1,A2&& a2,A3&& a3,A4&& a4)
|
||||
{
|
||||
void* const heap_memory=allocate_raw_heap_memory(sizeof(T));
|
||||
try
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try // BOOST_NO_EXCEPTIONS protected
|
||||
#endif
|
||||
{
|
||||
T* const data=new (heap_memory) T(static_cast<A1&&>(a1),static_cast<A2&&>(a2),
|
||||
static_cast<A3&&>(a3),static_cast<A4&&>(a4));
|
||||
return data;
|
||||
}
|
||||
catch(...)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
catch(...) // BOOST_NO_EXCEPTIONS protected
|
||||
{
|
||||
free_raw_heap_memory(heap_memory);
|
||||
throw;
|
||||
throw; // BOOST_NO_EXCEPTIONS protected
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
template<typename T,typename A1>
|
||||
inline T* heap_new_impl(A1 a1)
|
||||
{
|
||||
void* const heap_memory=allocate_raw_heap_memory(sizeof(T));
|
||||
try
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try // BOOST_NO_EXCEPTIONS protected
|
||||
#endif
|
||||
{
|
||||
T* const data=new (heap_memory) T(a1);
|
||||
return data;
|
||||
}
|
||||
catch(...)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
catch(...) // BOOST_NO_EXCEPTIONS protected
|
||||
{
|
||||
free_raw_heap_memory(heap_memory);
|
||||
throw;
|
||||
throw; // BOOST_NO_EXCEPTIONS protected
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T,typename A1,typename A2>
|
||||
inline T* heap_new_impl(A1 a1,A2 a2)
|
||||
{
|
||||
void* const heap_memory=allocate_raw_heap_memory(sizeof(T));
|
||||
try
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try // BOOST_NO_EXCEPTIONS protected
|
||||
#endif
|
||||
{
|
||||
T* const data=new (heap_memory) T(a1,a2);
|
||||
return data;
|
||||
}
|
||||
catch(...)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
catch(...) // BOOST_NO_EXCEPTIONS protected
|
||||
{
|
||||
free_raw_heap_memory(heap_memory);
|
||||
throw;
|
||||
throw; // BOOST_NO_EXCEPTIONS protected
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T,typename A1,typename A2,typename A3>
|
||||
inline T* heap_new_impl(A1 a1,A2 a2,A3 a3)
|
||||
{
|
||||
void* const heap_memory=allocate_raw_heap_memory(sizeof(T));
|
||||
try
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try // BOOST_NO_EXCEPTIONS protected
|
||||
#endif
|
||||
{
|
||||
T* const data=new (heap_memory) T(a1,a2,a3);
|
||||
return data;
|
||||
}
|
||||
catch(...)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
catch(...) // BOOST_NO_EXCEPTIONS protected
|
||||
{
|
||||
free_raw_heap_memory(heap_memory);
|
||||
throw;
|
||||
throw; // BOOST_NO_EXCEPTIONS protected
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T,typename A1,typename A2,typename A3,typename A4>
|
||||
inline T* heap_new_impl(A1 a1,A2 a2,A3 a3,A4 a4)
|
||||
{
|
||||
void* const heap_memory=allocate_raw_heap_memory(sizeof(T));
|
||||
try
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try // BOOST_NO_EXCEPTIONS protected
|
||||
#endif
|
||||
{
|
||||
T* const data=new (heap_memory) T(a1,a2,a3,a4);
|
||||
return data;
|
||||
}
|
||||
catch(...)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
catch(...) // BOOST_NO_EXCEPTIONS protected
|
||||
{
|
||||
free_raw_heap_memory(heap_memory);
|
||||
throw;
|
||||
throw; // BOOST_NO_EXCEPTIONS protected
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user