Modify

Opened 3 years ago

Closed 3 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));

Attachments (0)

Change History (2)

comment:1 Changed 3 years ago by viboes

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

comment:2 Changed 3 years ago by viboes

Resolution: fixed
Status: assignedclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain viboes.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.