Skip to content

Commit

Permalink
Merge pull request #1834 from STEllAR-GROUP/fixing_1832
Browse files Browse the repository at this point in the history
Making hpx::lcos::promise move-only
  • Loading branch information
hkaiser committed Oct 31, 2015
2 parents f6a23b1 + db1e126 commit 76f13eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
16 changes: 10 additions & 6 deletions examples/heartbeat/heartbeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#include <hpx/lcos/future.hpp>
#include <hpx/state.hpp>

#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/format.hpp>
#include <boost/cstdint.hpp>

Expand All @@ -25,9 +26,9 @@
#endif

///////////////////////////////////////////////////////////////////////////////
void stop_monitor(hpx::promise<void> p)
void stop_monitor(boost::shared_ptr<hpx::promise<void> > p)
{
p.set_value(); // Kill the monitor.
p->set_value(); // Kill the monitor.
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -56,11 +57,14 @@ int monitor(double runfor, std::string const& name, boost::uint64_t pause)
return 1;
}

hpx::promise<void> stop_flag;
hpx::register_shutdown_function(boost::bind(&stop_monitor, stop_flag));
boost::shared_ptr<hpx::promise<void> > stop_flag =
boost::make_shared<hpx::promise<void> >();
hpx::future<void> f = stop_flag->get_future();

hpx::register_shutdown_function(
hpx::util::bind(&stop_monitor, stop_flag));

boost::int64_t zero_time = 0;
hpx::future<void> f = stop_flag.get_future();

hpx::util::high_resolution_timer t;
while (runfor < 0 || t.elapsed() < runfor)
Expand Down
5 changes: 5 additions & 0 deletions hpx/lcos/promise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <hpx/lcos/local/spinlock_pool.hpp>
#include <hpx/util/one_size_heap_list_base.hpp>
#include <hpx/util/static_reinit.hpp>
#include <hpx/util/move.hpp>

#include <boost/intrusive_ptr.hpp>
#include <boost/static_assert.hpp>
Expand Down Expand Up @@ -544,6 +545,8 @@ namespace hpx { namespace lcos
template <typename Result, typename RemoteResult>
class promise
{
HPX_MOVABLE_BUT_NOT_COPYABLE(promise);

public:
typedef detail::promise<Result, RemoteResult> wrapped_type;
typedef components::managed_component<wrapped_type> wrapping_type;
Expand Down Expand Up @@ -664,6 +667,8 @@ namespace hpx { namespace lcos
template <>
class promise<void, util::unused_type>
{
HPX_MOVABLE_BUT_NOT_COPYABLE(promise);

public:
typedef detail::promise<void, util::unused_type> wrapped_type;
typedef components::managed_component<wrapped_type> wrapping_type;
Expand Down

0 comments on commit 76f13eb

Please sign in to comment.