<pre>static vector<Campfire> campfires; class Campfire { public: int lifeSpan; future<void> thread; Campfire(int _lifeSpan) { lifeSpan = _lifeSpan; } void Enable() { while (lifeSpan > 0) { Sleep(1000); lifeSpan--; cout << "Campfire Life Span: " << lifeSpan << endl; } Campfire *campfire = this; campfires.erase(campfire); delete(this); } ~Campfire() { cout << "Campfire has expired" << endl; } };
async(launch::async, &Campfire::Enable, freshCampfire);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)