| 107 | }; |
| 108 | |
| 109 | int main() |
| 110 | { |
| 111 | // tell the logger to output all messages |
| 112 | dlog.set_level(LALL); |
| 113 | |
| 114 | // Create an instance of our multi-threaded object. |
| 115 | my_object t; |
| 116 | |
| 117 | dlib::sleep(3000); |
| 118 | |
| 119 | // Tell the multi-threaded object to pause its threads. This causes the |
| 120 | // threads to block on their next calls to should_stop(). |
| 121 | t.pause(); |
| 122 | dlog << LINFO << "paused threads"; |
| 123 | |
| 124 | dlib::sleep(3000); |
| 125 | dlog << LINFO << "starting threads back up from paused state"; |
| 126 | |
| 127 | // Tell the threads to unpause themselves. This causes should_stop() to unblock |
| 128 | // and to let the threads continue. |
| 129 | t.start(); |
| 130 | |
| 131 | dlib::sleep(3000); |
| 132 | |
| 133 | // Let the program end. When t is destructed it will gracefully terminate your |
| 134 | // threads because we have set the destructor up to do so. |
| 135 | } |
| 136 | |
| 137 | |
| 138 | |