-
Resolve benchmark cleanup race condition in issue #20. · 54e18b89Chris Kennelly authored
The multithreaded API for benchmarks provides that teardown can happen in thread 0. For this to be safe, all other threads executing the benchmark function need to have exited. Otherwise, thread 0 may begin to teardown shared resources before the other threads have stopped using these resources as they are in their last loop of while (KeepRunning()) { ... }. This change creates a single exit point for KeepRunning() to return false. When running a multithreaded benchmark, thread 0 blocks on KeepRunning() until all other threads have exited. This approach allows for there to be no change to the user-facing API exemplified in the BM_MultiThreaded example.54e18b89
×