OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/task_scheduler/scheduler_worker_pool_impl.h" | 5 #include "base/task_scheduler/scheduler_worker_pool_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <unordered_set> | 10 #include <unordered_set> |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 } | 345 } |
346 | 346 |
347 // Verifies that the current thread allows I/O if |io_restriction| is ALLOWED | 347 // Verifies that the current thread allows I/O if |io_restriction| is ALLOWED |
348 // and disallows it otherwise. Signals |event| before returning. | 348 // and disallows it otherwise. Signals |event| before returning. |
349 void ExpectIORestriction(IORestriction io_restriction, WaitableEvent* event) { | 349 void ExpectIORestriction(IORestriction io_restriction, WaitableEvent* event) { |
350 DCHECK(event); | 350 DCHECK(event); |
351 | 351 |
352 if (io_restriction == IORestriction::ALLOWED) { | 352 if (io_restriction == IORestriction::ALLOWED) { |
353 ThreadRestrictions::AssertIOAllowed(); | 353 ThreadRestrictions::AssertIOAllowed(); |
354 } else { | 354 } else { |
355 static_assert( | |
356 ENABLE_THREAD_RESTRICTIONS == DCHECK_IS_ON(), | |
357 "ENABLE_THREAD_RESTRICTIONS and DCHECK_IS_ON() have diverged."); | |
358 EXPECT_DCHECK_DEATH({ ThreadRestrictions::AssertIOAllowed(); }, ""); | 355 EXPECT_DCHECK_DEATH({ ThreadRestrictions::AssertIOAllowed(); }, ""); |
359 } | 356 } |
360 | 357 |
361 event->Signal(); | 358 event->Signal(); |
362 } | 359 } |
363 | 360 |
364 class TaskSchedulerWorkerPoolImplIORestrictionTest | 361 class TaskSchedulerWorkerPoolImplIORestrictionTest |
365 : public testing::TestWithParam<IORestriction> { | 362 : public testing::TestWithParam<IORestriction> { |
366 public: | 363 public: |
367 TaskSchedulerWorkerPoolImplIORestrictionTest() = default; | 364 TaskSchedulerWorkerPoolImplIORestrictionTest() = default; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 count_waiter->Wait(); | 548 count_waiter->Wait(); |
552 | 549 |
553 EXPECT_GT(subtle::NoBarrier_Load(&zero_tls_values_), 0); | 550 EXPECT_GT(subtle::NoBarrier_Load(&zero_tls_values_), 0); |
554 | 551 |
555 // Release tasks waiting on |waiter_|. | 552 // Release tasks waiting on |waiter_|. |
556 waiter_.Signal(); | 553 waiter_.Signal(); |
557 } | 554 } |
558 | 555 |
559 } // namespace internal | 556 } // namespace internal |
560 } // namespace base | 557 } // namespace base |
OLD | NEW |