If I create an std::async object in a class, how long does the corresponding thread run? Until the desctructor of the containing class (Bar) is called?
class Bar {
public:
Bar() {
handle = std::async(
std::launch::async,
&Bar:foo, this);
}
...
void Foo() {
while (true) {//do stuff//}
}
private:
std::future<void> handle;
};
EDIT:
How long does the thread run in the following example:
class Bar {
public:
Bar() : thread(&Bar:foo, this) {
}
...
void Foo() {
while (true) {//do stuff//}
}
private:
std::thread thread;
};