Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Unified Diff: base/task_scheduler/scheduler_worker_pool_impl_unittest.cc

Issue 2628313004: Add TaskScheduler::JoinForTesting(). (Closed)
Patch Set: CR robliao #13 Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/task_scheduler/scheduler_worker_pool_impl_unittest.cc
diff --git a/base/task_scheduler/scheduler_worker_pool_impl_unittest.cc b/base/task_scheduler/scheduler_worker_pool_impl_unittest.cc
index dfaa9c7ff3d3a8071aceda80584d98eb447622d9..5d6a594ace33956a3b3b31518d717b5aef2f498d 100644
--- a/base/task_scheduler/scheduler_worker_pool_impl_unittest.cc
+++ b/base/task_scheduler/scheduler_worker_pool_impl_unittest.cc
@@ -485,8 +485,6 @@ TEST_F(TaskSchedulerWorkerPoolSingleThreadedTest, SingleThreadTask) {
// Give the worker pool a chance to reclaim its threads.
PlatformThread::Sleep(kReclaimTimeForDetachTests + kExtraTimeToWaitForDetach);
- worker_pool_->DisallowWorkerDetachmentForTesting();
-
single_thread_task_runner->PostTask(
FROM_HERE,
Bind(&TaskSchedulerWorkerPoolSingleThreadedTest::CheckValidThread,
@@ -563,8 +561,6 @@ TEST_F(TaskSchedulerWorkerPoolCheckTlsReuse, CheckDetachedThreads) {
// Give the worker pool a chance to detach its threads.
PlatformThread::Sleep(kReclaimTimeForDetachTests + kExtraTimeToWaitForDetach);
- worker_pool_->DisallowWorkerDetachmentForTesting();
-
// Saturate and count the threads that do not have the magic TLS value. If the
// value is not there, that means we're at a new thread.
std::vector<std::unique_ptr<WaitableEvent>> count_waiters;
@@ -715,8 +711,10 @@ TEST_F(TaskSchedulerWorkerPoolHistogramTest, NumTasksBetweenWaitsWithDetach) {
EXPECT_EQ(0, histogram->SnapshotSamples()->GetCount(10));
tasks_can_exit_event.Signal();
+
+ // Do not let |tasks_can_exit_event| go out of scope before all workers are
+ // idle.
worker_pool_->WaitForAllWorkersIdleForTesting();
- worker_pool_->DisallowWorkerDetachmentForTesting();
}
namespace {
@@ -764,7 +762,6 @@ TEST_F(TaskSchedulerWorkerPoolHistogramTest, NumTasksBeforeDetach) {
// Allow the SchedulerWorker that was associated with |task_runner| to detach.
PlatformThread::Sleep(kReclaimTimeForDetachTests + kExtraTimeToWaitForDetach);
- worker_pool_->DisallowWorkerDetachmentForTesting();
// Verify that counts were recorded to the histogram as expected.
const auto* histogram = worker_pool_->num_tasks_before_detach_histogram();

Powered by Google App Engine
This is Rietveld 408576698