| 27 | } |
| 28 | |
| 29 | ~my_object() |
| 30 | { |
| 31 | // Tell the thread() function to stop. This will cause should_stop() to |
| 32 | // return true so the thread knows what to do. |
| 33 | stop(); |
| 34 | |
| 35 | // Wait for the thread to stop before letting this object destruct itself. |
| 36 | // Also note, you are *required* to wait for the thread to end before |
| 37 | // letting this object destruct itself. |
| 38 | wait(); |
| 39 | } |
| 40 | |
| 41 | private: |
| 42 |