emscripten-core / emscripten-core/emscripten
Runtime not exited after `std::async`
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 109
Description
I build with the following options an autotest with emscripten 3.1.35:
`pthread PROXY_TO_PTHREAD emrun EXIT_RUNTIME ASYNCIFY`
Then I have a time-long method I want to execute.
If directly executed in the `main()`, the runtime exits correctly at the end of the test.
```C
int main(int argc, char** argv)
{
double result{0.};
for(auto i=0 ; i<100'000'000 ; ++i)
result += std::cos(i);
std::cout << "Result is " << result << "\n";
}
```
If doing the same with `std::async`, the runtime is never exited (then the test result cannot be known by the IDE)
```C
int main(int argc, char** argv)
{
auto result = std::async([]() -> double {
double result{0.};
for(auto i=0 ; i<100'000'000 ; ++i)
result += std::cos(i);
return result;
});
std::cout << "Result is " << result.get() << "\n";
}
```
I would expect that the program ends also in that case.
How can I make it exit ?
Contributor guide
Assessment
This issue has not been assessed yet.