diff options
Diffstat (limited to 'boost/fiber/future/packaged_task.hpp')
-rw-r--r-- | boost/fiber/future/packaged_task.hpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/boost/fiber/future/packaged_task.hpp b/boost/fiber/future/packaged_task.hpp index 31838ee41f..c8b10d43e0 100644 --- a/boost/fiber/future/packaged_task.hpp +++ b/boost/fiber/future/packaged_task.hpp @@ -14,7 +14,6 @@ #include <boost/config.hpp> -#include <boost/fiber/detail/convert.hpp> #include <boost/fiber/detail/disable_overload.hpp> #include <boost/fiber/exceptions.hpp> #include <boost/fiber/future/detail/task_base.hpp> @@ -57,16 +56,18 @@ public: typedef std::allocator_traits< typename object_type::allocator_type > traits_type; + typedef pointer_traits< typename traits_type::pointer > ptrait_type; typename object_type::allocator_type a{ alloc }; typename traits_type::pointer ptr{ traits_type::allocate( a, 1) }; + typename ptrait_type::element_type* p = ptrait_type::to_address(ptr); try { - traits_type::construct( a, ptr, a, std::forward< Fn >( fn) ); + traits_type::construct( a, p, a, std::forward< Fn >( fn) ); } catch (...) { traits_type::deallocate( a, ptr, 1); throw; } - task_.reset( convert( ptr) ); + task_.reset(p); } ~packaged_task() { @@ -85,7 +86,7 @@ public: } packaged_task & operator=( packaged_task && other) noexcept { - if ( this != & other) { + if ( BOOST_LIKELY( this != & other) ) { packaged_task tmp{ std::move( other) }; swap( tmp); } @@ -105,7 +106,7 @@ public: if ( obtained_) { throw future_already_retrieved{}; } - if ( ! valid() ) { + if ( BOOST_UNLIKELY( ! valid() ) ) { throw packaged_task_uninitialized{}; } obtained_ = true; @@ -114,14 +115,14 @@ public: } void operator()( Args ... args) { - if ( ! valid() ) { + if ( BOOST_UNLIKELY( ! valid() ) ) { throw packaged_task_uninitialized{}; } task_->run( std::forward< Args >( args) ... ); } void reset() { - if ( ! valid() ) { + if ( BOOST_UNLIKELY( ! valid() ) ) { throw packaged_task_uninitialized{}; } packaged_task tmp; |