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

Asynchronous tasks outlive main thread #1

Closed
dpaulat opened this issue Feb 13, 2022 · 1 comment
Closed

Asynchronous tasks outlive main thread #1

dpaulat opened this issue Feb 13, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@dpaulat
Copy link
Owner

dpaulat commented Feb 13, 2022

template<class F>
void async(F&& f)
{
auto future = std::make_shared<std::future<void>>();
*future = std::async(std::launch::async, [future, f]() { f(); });
}

Because futures are not tracked, if the application exits while an asynchronous operation is still running, undefined behavior can occur within those operations.

A mechanism needs to be created to track these futures and wait for asynchronous tasks to complete.

@dpaulat
Copy link
Owner Author

dpaulat commented May 28, 2022

Resolved by bb7793d

@dpaulat dpaulat closed this as completed May 28, 2022
@dpaulat dpaulat added the bug Something isn't working label Dec 17, 2022
dpaulat pushed a commit that referenced this issue Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant