-
Notifications
You must be signed in to change notification settings - Fork 75
Closed
Labels
Description
In the following code, the recovery continuation is never executed with the broken promise exception, instead, it is destructed.
#include <stlab/concurrency/future.hpp>
#include <stlab/concurrency/immediate_executor.hpp>
#include <stlab/concurrency/utility.hpp>
#include <iostream>
using namespace stlab;
using namespace std;
int main() {
auto hold = []() {
auto [promise, future]{ package<int(int)>(immediate_executor, [](int x){ return x; })};
return future ^ [](const auto& f) {
try {
auto answer = *f.get_try();
cout << "The answer is " << answer << '\n';
}
catch (const exception& ex) {
cout << "The error \"" << ex.what() << "\" happened!\n";
}
};
}();
cout << "has exception:" << !!hold.exception() << endl;
}The broken promise code predates recovery continuations, the code should execute the recovery continuations before destruction.