Skip to content

Recovery continuations not invoked on broken promises #346

@sean-parent

Description

@sean-parent

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions