| 13 | namespace fusion { |
| 14 | |
| 15 | class thread : private std::thread |
| 16 | { |
| 17 | public: |
| 18 | thread(std::function<void()> fn) : std::thread(fn) |
| 19 | { |
| 20 | } |
| 21 | |
| 22 | ~thread() |
| 23 | { |
| 24 | assert(!joinable() && "Always join the thread before releasing it"); |
| 25 | } |
| 26 | |
| 27 | void join() |
| 28 | { |
| 29 | if (joinable()) std::thread::join(); |
| 30 | } |
| 31 | |
| 32 | void detach() |
| 33 | { |
| 34 | assert(!joinable() && "Cannot detach an unjoinable thread"); |
| 35 | std::thread::detach(); |
| 36 | } |
| 37 | |
| 38 | id get_id() const |
| 39 | { |
| 40 | std::thread::get_id(); |
| 41 | } |
| 42 | }; |
| 43 | |
| 44 | } // namespace fusion |