Skip to content

Commit

Permalink
Merge pull request #1835 from STEllAR-GROUP/moving_promise
Browse files Browse the repository at this point in the history
Adding exlicit move constructor and assignment operator
  • Loading branch information
hkaiser committed Nov 1, 2015
2 parents 76f13eb + 78bfbc2 commit 343f41e
Showing 1 changed file with 56 additions and 10 deletions.
66 changes: 56 additions & 10 deletions hpx/lcos/promise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,6 @@ namespace hpx { namespace lcos { namespace detail
// actual managed component object
~promise()
{
// This lock is needed to not interfere with the intrusive pointer
// deletion
this->finalize();
}

Expand Down Expand Up @@ -359,8 +357,6 @@ namespace hpx { namespace lcos { namespace detail
// actual managed component object
~promise()
{
// This lock is needed to not interfere with the intrusive pointer
// deletion
this->finalize();
}

Expand Down Expand Up @@ -573,6 +569,27 @@ namespace hpx { namespace lcos
<< impl_->get_unmanaged_id() << ")";
}

promise(promise && rhs)
: impl_(std::move(rhs.impl_)),
future_obtained_(rhs.future_obtained_)
{
rhs.future_obtained_ = false;
}

virtual ~promise()
{}

promise& operator=(promise && rhs)
{
if (this != &rhs)
{
impl_ = std::move(rhs.impl_);
future_obtained_ = rhs.future_obtained_;
rhs.future_obtained_ = false;
}
return *this;
}

protected:
template <typename Impl>
promise(Impl* impl)
Expand All @@ -599,6 +616,13 @@ namespace hpx { namespace lcos
return (*impl_)->get_unmanaged_id();
}

#if defined(HPX_HAVE_COMPONENT_GET_GID_COMPATIBILITY)
naming::id_type get_gid() const
{
return get_id();
}
#endif

private:
// Return the global id of this \a future instance
naming::gid_type get_base_gid() const
Expand All @@ -622,9 +646,6 @@ namespace hpx { namespace lcos

typedef Result result_type;

virtual ~promise()
{}

lcos::future<Result> get_future(error_code& ec = throws)
{
if (future_obtained_) {
Expand Down Expand Up @@ -694,6 +715,27 @@ namespace hpx { namespace lcos
<< impl_->get_unmanaged_id() << ")";
}

promise(promise && rhs)
: impl_(std::move(rhs.impl_)),
future_obtained_(rhs.future_obtained_)
{
rhs.future_obtained_ = false;
}

virtual ~promise()
{}

promise& operator=(promise && rhs)
{
if (this != &rhs)
{
impl_ = std::move(rhs.impl_);
future_obtained_ = rhs.future_obtained_;
rhs.future_obtained_ = false;
}
return *this;
}

protected:
template <typename Impl>
promise(Impl* impl)
Expand All @@ -720,6 +762,13 @@ namespace hpx { namespace lcos
return (*impl_)->get_unmanaged_id();
}

#if defined(HPX_HAVE_COMPONENT_GET_GID_COMPATIBILITY)
naming::id_type get_gid() const
{
return get_id();
}
#endif

private:
/// \brief Return the global id of this \a future instance
naming::gid_type get_base_gid() const
Expand All @@ -737,9 +786,6 @@ namespace hpx { namespace lcos

typedef util::unused_type result_type;

virtual ~promise()
{}

lcos::future<void> get_future(error_code& ec = throws)
{
if (future_obtained_) {
Expand Down

0 comments on commit 343f41e

Please sign in to comment.