Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify promise #2223

Merged
merged 19 commits into from Jun 23, 2016
Merged

Simplify promise #2223

merged 19 commits into from Jun 23, 2016

Conversation

sithhell
Copy link
Member

This patch introduces a simplified redesign for hpx:lcos::promise.
It tries to simplify the current implementation by splitting up the shared_state, promise and lco component into three different classes. This makes the referencing scheme a little more obvious and therefor is able to remove the global reference counting alltogether by creating a cycle between the component and the shared state which is explicitly broken once the shared_state is set ready.

Thomas Heller and others added 18 commits June 10, 2016 13:45
Calling package_action::get_future after package_action::apply might lead to
a rare race condition in the  lifetime management of the lcos::promise shared
state
Making sure that the managed id return from the promise actually contains credit
that keeps the shared state alive.
- make sure that traits usage has proper headers
- flyby: adding missing #includes
Calling package_action::get_future after package_action::apply might lead to
a rare race condition in the  lifetime management of the lcos::promise shared
state
This patch is simplifying hpx::lcos::promise by defining it in terms of
hpx::lcos::local::detail::promise_base and a separate class which implements
the lco interface. This decouples the future shared state reference counting
from the reference counting needed for the LCO component. We now have local
only reference counting.
Conflicts:
	hpx/lcos/detail/async_implementations.hpp
	hpx/lcos/promise.hpp
	tests/unit/agas/components/managed_refcnt_checker.hpp
	tests/unit/agas/components/simple_refcnt_checker.hpp
	tests/unit/parcelset/put_parcels.cpp
@@ -0,0 +1,222 @@
// Copyright (c) 2007-2015 Hartmut Kaiser
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this file: please don't align assignments, variable names, etc.

@hkaiser
Copy link
Member

hkaiser commented Jun 22, 2016

General question: will the shared state be ever released if the value is never set? I.e. will this be memory-leak free:

{
    hpx::lcos:promise<void> p;
    p.get_id();
}

?

"this promise has no valid LCO");
return naming::invalid_id;
}
if (!this->future_retrieved_)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you still have to ensure that the future is retrieved before the get_id() was called? Or is that a left-over?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still have to do that.

@@ -308,21 +310,20 @@ namespace hpx { namespace lcos
<< hpx::actions::detail::get_action_name<action_type>()
<< ", " << id << ") args(" << sizeof...(Ts) << ")";

auto cb = util::bind(&packaged_action::parcel_write_handler,
this->shared_state_, _1, _2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here and more places below.

@hkaiser
Copy link
Member

hkaiser commented Jun 22, 2016

All in all, LGTM. Please correct the minor issues and we can go ahead with this. Thanks a lot!

@hkaiser hkaiser merged commit 9bf379e into master Jun 23, 2016
@hkaiser hkaiser deleted the simplify_promise branch June 23, 2016 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants