Closed
Description
No idea why this is different from regular threads.
#include <thread>
#include <future>
#include <iostream>
int main(int argc, char** argv) {
//works
std::thread([] {
std::cout << "Thread ID: " << std::this_thread::get_id() << std::endl;
}).detach();
//hangs
std::async([] {
std::cout << "Thread ID: " << std::this_thread::get_id() << std::endl;
});
}
Compile with: emcc test.cpp -std=c++11 -s USE_PTHREADS=1 -o test.html
to see the issue.
Compile with: emcc test.cpp -std=c++11 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=2 -o test.html
to make this work as expected.