Opened 8 years ago

Closed 8 years ago

#10552 closed Feature Requests (fixed)

Add make_valid_future

Reported by: viboes Owned by: viboes
Milestone: Boost 1.57.0 Component: thread
Version: Boost 1.56.0 Severity: Problem
Keywords: Cc:

Description

Some functions require that the future are valid.

The needs to check for the validity before using these futures.

if (fut.valid()) {
  auto x = fut.then(fct);
}
if (f1.valid() && f2.valid()) {
  auto x = when_all(f1, f2);
}

An alternative is to provide a make_valid_future function that ensure that the result is valid. If the input future is valid it return the same future, otherwise it sets an exception future_error, and the corresponding error condition would be std::future_errc::no_state.

In this way the user can always use it as

auto x = make_valid_future(fut).then(fct);

auto y = when_all(make_valid_future(f1), make_valid_future(f2));

Change History (2)

comment:1 by viboes, 8 years ago

Milestone: To Be DeterminedBoost 1.57.0
Owner: changed from Anthony Williams to viboes
Status: newassigned

comment:2 by viboes, 8 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.