| 285 | } |
| 286 | |
| 287 | void pause() { |
| 288 | { |
| 289 | std::lock_guard<std::mutex> lock(mtx); |
| 290 | |
| 291 | if (!running) { |
| 292 | return; |
| 293 | } |
| 294 | |
| 295 | running = false; |
| 296 | |
| 297 | // push an entry to signal the worker thread to stop |
| 298 | { |
| 299 | auto & entry = entries[tail]; |
| 300 | entry.is_end = true; |
| 301 | |
| 302 | tail = (tail + 1) % entries.size(); |
| 303 | } |
| 304 | |
| 305 | cv.notify_one(); |
| 306 | } |
| 307 | |
| 308 | thrd.join(); |
| 309 | } |
| 310 | |
| 311 | void set_file(const char * path) { |
| 312 | pause(); |
no test coverage detected