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