| 71 | } |
| 72 | |
| 73 | ~my_object() |
| 74 | { |
| 75 | // Tell the thread() function to stop. This will cause should_stop() to |
| 76 | // return true so the thread knows what to do. |
| 77 | stop(); |
| 78 | |
| 79 | // Wait for the threads to stop before letting this object destruct itself. |
| 80 | // Also note, you are *required* to wait for the threads to end before |
| 81 | // letting this object destruct itself. |
| 82 | wait(); |
| 83 | } |
| 84 | |
| 85 | private: |
| 86 |