summaryrefslogtreecommitdiff
path: root/boost/fiber/future/promise.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-09-13 11:24:46 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-09-13 11:25:39 +0900
commit4fadd968fa12130524c8380f33fcfe25d4de79e5 (patch)
treefd26a490cd15388d42fc6652b3c5c13012e7f93e /boost/fiber/future/promise.hpp
parentb5c87084afaef42b2d058f68091be31988a6a874 (diff)
downloadboost-4fadd968fa12130524c8380f33fcfe25d4de79e5.tar.gz
boost-4fadd968fa12130524c8380f33fcfe25d4de79e5.tar.bz2
boost-4fadd968fa12130524c8380f33fcfe25d4de79e5.zip
Imported Upstream version 1.65.0upstream/1.65.0
Change-Id: Icf8400b375482cb11bcf77440a6934ba360d6ba4 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/fiber/future/promise.hpp')
-rw-r--r--boost/fiber/future/promise.hpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/boost/fiber/future/promise.hpp b/boost/fiber/future/promise.hpp
index 83ba63fb23..661c8b0480 100644
--- a/boost/fiber/future/promise.hpp
+++ b/boost/fiber/future/promise.hpp
@@ -12,8 +12,8 @@
#include <utility>
#include <boost/config.hpp>
+#include <boost/core/pointer_traits.hpp>
-#include <boost/fiber/detail/convert.hpp>
#include <boost/fiber/exceptions.hpp>
#include <boost/fiber/future/detail/shared_state.hpp>
#include <boost/fiber/future/detail/shared_state_object.hpp>
@@ -38,16 +38,18 @@ struct promise_base {
promise_base( std::allocator_arg_t, Allocator alloc) {
typedef detail::shared_state_object< R, Allocator > object_type;
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);
+ traits_type::construct( a, p, a);
} catch (...) {
traits_type::deallocate( a, ptr, 1);
throw;
}
- future_.reset( convert( ptr) );
+ future_.reset(p);
}
~promise_base() {
@@ -66,7 +68,7 @@ struct promise_base {
}
promise_base & operator=( promise_base && other) noexcept {
- if ( this != & other) {
+ if ( BOOST_LIKELY( this != & other) ) {
promise_base tmp{ std::move( other) };
swap( tmp);
}
@@ -74,10 +76,10 @@ struct promise_base {
}
future< R > get_future() {
- if ( obtained_) {
+ if ( BOOST_UNLIKELY( obtained_) ) {
throw future_already_retrieved{};
}
- if ( ! future_) {
+ if ( BOOST_UNLIKELY( ! future_) ) {
throw promise_uninitialized{};
}
obtained_ = true;
@@ -90,7 +92,7 @@ struct promise_base {
}
void set_exception( std::exception_ptr p) {
- if ( ! future_) {
+ if ( BOOST_UNLIKELY( ! future_) ) {
throw promise_uninitialized{};
}
future_->set_exception( p);
@@ -119,14 +121,14 @@ public:
promise & operator=( promise && other) = default;
void set_value( R const& value) {
- if ( ! base_type::future_) {
+ if ( BOOST_UNLIKELY( ! base_type::future_) ) {
throw promise_uninitialized{};
}
base_type::future_->set_value( value);
}
void set_value( R && value) {
- if ( ! base_type::future_) {
+ if ( BOOST_UNLIKELY( ! base_type::future_) ) {
throw promise_uninitialized{};
}
base_type::future_->set_value( std::move( value) );
@@ -160,7 +162,7 @@ public:
promise & operator=( promise && other) noexcept = default;
void set_value( R & value) {
- if ( ! base_type::future_) {
+ if ( BOOST_UNLIKELY( ! base_type::future_) ) {
throw promise_uninitialized{};
}
base_type::future_->set_value( value);
@@ -195,7 +197,7 @@ public:
inline
void set_value() {
- if ( ! base_type::future_) {
+ if ( BOOST_UNLIKELY( ! base_type::future_) ) {
throw promise_uninitialized{};
}
base_type::future_->set_value();