| … | … | @@ -499,10 +499,13 @@ void async_buffer<Writer, Element>::write_loop() |
| 499 | 499 | if (_current_barrier != nullptr) |
| 500 | 500 | { |
| 501 | 501 | (_writer->*_do_write)(*_current_barrier); |
| 502 | _barrier_count--; | |
| 503 | _barrier_count.notify_all(); | |
| 504 | 502 | |
| 505 | // Wait for barrier to complete | |
| 503 | unsigned int old_count = _barrier_count.fetch_sub(1); | |
| 504 | if (2 == old_count) | |
| 505 | _barrier_count.notify_all(); | |
| 506 | ||
| 507 | // barrier() will drop the count to zero after | |
| 508 | // all workers have run. | |
| 506 | 509 | unsigned cnt = _barrier_count.load(); |
| 507 | 510 | while (0 < cnt) |
| 508 | 511 | { |