! * \brief constructor * \param thread thread to manage */
| 36 | * \param thread thread to manage |
| 37 | */ |
| 38 | explicit ScopedThread(std::thread thread) |
| 39 | : thread_(std::move(thread)) { |
| 40 | if (!thread_.joinable()) { |
| 41 | throw std::logic_error("No thread"); |
| 42 | } |
| 43 | } |
| 44 | // destructor: join upon destruction |
| 45 | virtual ~ScopedThread() { |
| 46 | thread_.join(); |