Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recovery continuations not invoked on broken promises #346

Closed
sean-parent opened this issue Jan 19, 2021 · 5 comments
Closed

Recovery continuations not invoked on broken promises #346

sean-parent opened this issue Jan 19, 2021 · 5 comments
Assignees

Comments

@sean-parent
Copy link
Member

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.

@FelixPetriconi FelixPetriconi self-assigned this Jan 19, 2021
@FelixPetriconi
Copy link
Member

I will look into this.

@KevinHopps
Copy link
Contributor

@FelixPetriconi, do you have an ETA for this fix?

@FelixPetriconi
Copy link
Member

I have a fix inside a PR. I am waiting for a review.

@fpelliccioni fpelliccioni mentioned this issue Jan 22, 2021
@KevinHopps
Copy link
Contributor

I have a fix inside a PR. I am waiting for a review.

Thanks!

@FelixPetriconi
Copy link
Member

Fixed in 1.5.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants