Skip to content

Instantly share code, notes, and snippets.

@arcticmatt
Created January 9, 2020 06:39
Show Gist options
  • Save arcticmatt/f04cdeea66223a2a52ffaa74ad8fa7bb to your computer and use it in GitHub Desktop.
Save arcticmatt/f04cdeea66223a2a52ffaa74ad8fa7bb to your computer and use it in GitHub Desktop.
template <typename Function>
class RaiiThread {
public:
RaiiThread(Function &&f) : t_(f){};
~RaiiThread() {
std::cout << "Joining thread in ~RaiiThread" << std::endl;
t_.join();
};
private:
std::thread t_;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment