The async
call below is blocking because the destructor of the returned future is blocking:
void foo() {}
void foo_async() {
std::async(std::launch::async, foo);
}
But I don't want to block!
I'm considering to use the following workaround:
void foo_async() {
std::thread(foo).detach();
}
Is this ok? Or would you recommend a different solution?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…