update boost on linux
This commit is contained in:
@@ -62,7 +62,7 @@ protected:
|
||||
|
||||
void set_exception_( std::exception_ptr except, std::unique_lock< mutex > & lk) {
|
||||
BOOST_ASSERT( lk.owns_lock() );
|
||||
if ( ready_) {
|
||||
if ( BOOST_UNLIKELY( ready_) ) {
|
||||
throw promise_already_satisfied();
|
||||
}
|
||||
except_ = except;
|
||||
@@ -161,19 +161,19 @@ private:
|
||||
|
||||
void set_value_( R const& value, std::unique_lock< mutex > & lk) {
|
||||
BOOST_ASSERT( lk.owns_lock() );
|
||||
if ( ready_) {
|
||||
if ( BOOST_UNLIKELY( ready_) ) {
|
||||
throw promise_already_satisfied{};
|
||||
}
|
||||
::new ( static_cast< void * >( std::addressof( storage_) ) ) R{ value };
|
||||
::new ( static_cast< void * >( std::addressof( storage_) ) ) R( value );
|
||||
mark_ready_and_notify_( lk);
|
||||
}
|
||||
|
||||
void set_value_( R && value, std::unique_lock< mutex > & lk) {
|
||||
BOOST_ASSERT( lk.owns_lock() );
|
||||
if ( ready_) {
|
||||
if ( BOOST_UNLIKELY( ready_) ) {
|
||||
throw promise_already_satisfied{};
|
||||
}
|
||||
::new ( static_cast< void * >( std::addressof( storage_) ) ) R{ std::move( value) };
|
||||
::new ( static_cast< void * >( std::addressof( storage_) ) ) R( std::move( value) );
|
||||
mark_ready_and_notify_( lk);
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ private:
|
||||
|
||||
void set_value_( R & value, std::unique_lock< mutex > & lk) {
|
||||
BOOST_ASSERT( lk.owns_lock() );
|
||||
if ( ready_) {
|
||||
if ( BOOST_UNLIKELY( ready_) ) {
|
||||
throw promise_already_satisfied();
|
||||
}
|
||||
value_ = std::addressof( value);
|
||||
@@ -266,7 +266,7 @@ private:
|
||||
inline
|
||||
void set_value_( std::unique_lock< mutex > & lk) {
|
||||
BOOST_ASSERT( lk.owns_lock() );
|
||||
if ( ready_) {
|
||||
if ( BOOST_UNLIKELY( ready_) ) {
|
||||
throw promise_already_satisfied();
|
||||
}
|
||||
mark_ready_and_notify_( lk);
|
||||
|
||||
@@ -44,8 +44,9 @@ private:
|
||||
|
||||
static void destroy_( allocator_type const& alloc, shared_state_object * p) noexcept {
|
||||
allocator_type a{ alloc };
|
||||
a.destroy( p);
|
||||
a.deallocate( p, 1);
|
||||
typedef std::allocator_traits< allocator_type > traity_type;
|
||||
traity_type::destroy( a, p);
|
||||
traity_type::deallocate( a, p, 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -13,9 +13,11 @@
|
||||
#include <utility>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/context/detail/config.hpp>
|
||||
#if defined(BOOST_NO_CXX17_STD_APPLY)
|
||||
#include <boost/context/detail/apply.hpp>
|
||||
#endif
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
|
||||
#include <boost/fiber/detail/config.hpp>
|
||||
#include <boost/fiber/future/detail/task_base.hpp>
|
||||
@@ -32,9 +34,10 @@ template< typename Fn, typename Allocator, typename R, typename ... Args >
|
||||
class task_object : public task_base< R, Args ... > {
|
||||
private:
|
||||
typedef task_base< R, Args ... > base_type;
|
||||
typedef std::allocator_traits< Allocator > allocator_traits;
|
||||
|
||||
public:
|
||||
typedef typename std::allocator_traits< Allocator >::template rebind_alloc<
|
||||
typedef typename allocator_traits::template rebind_alloc<
|
||||
task_object
|
||||
> allocator_type;
|
||||
|
||||
@@ -61,6 +64,10 @@ public:
|
||||
fn_, std::make_tuple( std::forward< Args >( args) ... ) )
|
||||
#endif
|
||||
);
|
||||
#if defined(BOOST_CONTEXT_HAS_CXXABI_H)
|
||||
} catch ( abi::__forced_unwind const&) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (...) {
|
||||
this->set_exception( std::current_exception() );
|
||||
}
|
||||
@@ -68,15 +75,17 @@ public:
|
||||
|
||||
typename base_type::ptr_type reset() override final {
|
||||
typedef std::allocator_traits< allocator_type > traity_type;
|
||||
typedef pointer_traits< typename traity_type::pointer> ptrait_type;
|
||||
|
||||
typename traity_type::pointer ptr{ traity_type::allocate( alloc_, 1) };
|
||||
typename ptrait_type::element_type* p = boost::to_address(ptr);
|
||||
try {
|
||||
traity_type::construct( alloc_, ptr, alloc_, std::move( fn_) );
|
||||
traity_type::construct( alloc_, p, alloc_, std::move( fn_) );
|
||||
} catch (...) {
|
||||
traity_type::deallocate( alloc_, ptr, 1);
|
||||
throw;
|
||||
}
|
||||
return { convert( ptr) };
|
||||
return { p };
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -90,8 +99,9 @@ private:
|
||||
|
||||
static void destroy_( allocator_type const& alloc, task_object * p) noexcept {
|
||||
allocator_type a{ alloc };
|
||||
a.destroy( p);
|
||||
a.deallocate( p, 1);
|
||||
typedef std::allocator_traits< allocator_type > traity_type;
|
||||
traity_type::destroy( a, p);
|
||||
traity_type::deallocate( a, p, 1);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -99,11 +109,12 @@ template< typename Fn, typename Allocator, typename ... Args >
|
||||
class task_object< Fn, Allocator, void, Args ... > : public task_base< void, Args ... > {
|
||||
private:
|
||||
typedef task_base< void, Args ... > base_type;
|
||||
typedef std::allocator_traits< Allocator > allocator_traits;
|
||||
|
||||
public:
|
||||
typedef typename Allocator::template rebind<
|
||||
typedef typename allocator_traits::template rebind_alloc<
|
||||
task_object< Fn, Allocator, void, Args ... >
|
||||
>::other allocator_type;
|
||||
> allocator_type;
|
||||
|
||||
task_object( allocator_type const& alloc, Fn const& fn) :
|
||||
base_type{},
|
||||
@@ -127,6 +138,10 @@ public:
|
||||
fn_, std::make_tuple( std::forward< Args >( args) ... ) );
|
||||
#endif
|
||||
this->set_value();
|
||||
#if defined(BOOST_CONTEXT_HAS_CXXABI_H)
|
||||
} catch ( abi::__forced_unwind const&) {
|
||||
throw;
|
||||
#endif
|
||||
} catch (...) {
|
||||
this->set_exception( std::current_exception() );
|
||||
}
|
||||
@@ -134,15 +149,17 @@ public:
|
||||
|
||||
typename base_type::ptr_type reset() override final {
|
||||
typedef std::allocator_traits< allocator_type > traity_type;
|
||||
typedef pointer_traits< typename traity_type::pointer> ptrait_type;
|
||||
|
||||
typename traity_type::pointer ptr{ traity_type::allocate( alloc_, 1) };
|
||||
typename ptrait_type::element_type* p = boost::to_address(ptr);
|
||||
try {
|
||||
traity_type::construct( alloc_, ptr, alloc_, std::move( fn_) );
|
||||
traity_type::construct( alloc_, p, alloc_, std::move( fn_) );
|
||||
} catch (...) {
|
||||
traity_type::deallocate( alloc_, ptr, 1);
|
||||
throw;
|
||||
}
|
||||
return { convert( ptr) };
|
||||
return { p };
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -156,8 +173,9 @@ private:
|
||||
|
||||
static void destroy_( allocator_type const& alloc, task_object * p) noexcept {
|
||||
allocator_type a{ alloc };
|
||||
a.destroy( p);
|
||||
a.deallocate( p, 1);
|
||||
typedef std::allocator_traits< allocator_type > traity_type;
|
||||
traity_type::destroy( a, p);
|
||||
traity_type::deallocate( a, p, 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user