From 7947b544d2e716be16f7d9a5324a436b901780f7 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Sun, 9 Nov 2014 12:30:50 -0800 Subject: Fix thread pool test valgrind flakiness The test used to use the counters to see when the tasks were done but since the counter is incremented before finalize was called, the test would sometimes finish before the objects were freed. This resulted in valgrind leaks. Change-Id: I6dc3cf6a155cde3af5d06b1416773a6ae6f2a6e6 --- runtime/thread_pool_test.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/runtime/thread_pool_test.cc b/runtime/thread_pool_test.cc index 4bd44dc..d5f17d1 100644 --- a/runtime/thread_pool_test.cc +++ b/runtime/thread_pool_test.cc @@ -95,11 +95,7 @@ TEST_F(ThreadPoolTest, StopStart) { EXPECT_EQ(0, bad_count.LoadSequentiallyConsistent()); // Allow tasks to finish up and delete themselves. thread_pool.StartWorkers(self); - while (count.LoadSequentiallyConsistent() != num_tasks && - bad_count.LoadSequentiallyConsistent() != 1) { - usleep(200); - } - thread_pool.StopWorkers(self); + thread_pool.Wait(self, false, false); } class TreeTask : public Task { -- cgit v1.1