| 269 | } |
| 270 | |
| 271 | void pause() { |
| 272 | { |
| 273 | std::lock_guard<std::mutex> lock(mtx); |
| 274 | |
| 275 | if (!running) { |
| 276 | return; |
| 277 | } |
| 278 | |
| 279 | running = false; |
| 280 | |
| 281 | // push an entry to signal the worker thread to stop |
| 282 | { |
| 283 | auto & entry = entries[tail]; |
| 284 | entry.is_end = true; |
| 285 | |
| 286 | tail = (tail + 1) % entries.size(); |
| 287 | } |
| 288 | |
| 289 | cv.notify_one(); |
| 290 | } |
| 291 | |
| 292 | thrd.join(); |
| 293 | } |
| 294 | |
| 295 | void set_file(const char * path) { |
| 296 | pause(); |
no test coverage detected