[
https://issues.apache.org/jira/browse/MESOS-9369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16674075#comment-16674075
]
Benjamin Bannier commented on MESOS-9369:
-----------------------------------------
For all wrapper types in stout {{get}} currently always asserts that instances
are in a state where the wrapped value can be safely extracted (i.e., we assert
{{isSome}} for all {{get}} methods of {{Option}}, {{Try}} and {{Result}}).
With the approach suggested here {{Future::get}} would assert that _eventually_
the {{Future}} would be ready; it seems that asserting that the {{Future}} is
ready _right now_ would be more in line with what we do in stout, i.e.,
{{Future::get}} should crash if the {{Future}} is not ready. This ticket is an
indication that the current semantics of {{Future::get}} are confusing.
----
I am not sure we would need to expose a function performing _implicit_,
blocking await. This would seem to subvert the programming model of libprocess
(e.g., continuations instead of blocking), but directly in libprocess instead
of as a user hack. Also, it is already possible to await explicitly,
{code:java}
Future<bool> f = fun();
/// Blocking approach with explicit `await`.
f.await();
CHECK(f.isReady());
if (f.get()) {
// Do stuff.
}
/// Better libprocess'y approach?
auto done = f.then([](const bool b) {
if (b) {
// Do stuff.
}
});
// Propagate `done`.
{code}
> Avoid blocking `Future::get()` calls
> ------------------------------------
>
> Key: MESOS-9369
> URL: https://issues.apache.org/jira/browse/MESOS-9369
> Project: Mesos
> Issue Type: Improvement
> Components: libprocess
> Reporter: Chun-Hung Hsiao
> Assignee: Chun-Hung Hsiao
> Priority: Major
> Labels: libprocess
>
> {{Future::get()}} does a wait if the future is still pending. If this is
> accidentally called in an actor, the actor will be blocked. We should avoid
> calling {{Future::get()}} in the code. The plan would be:
> # Introduce {{Future::value()}}: crash if not READY
> # Make {{Future::operator*}} and {{Future::operator->}} akin to
> {{Future::value()}}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)