| Index: base/threading/sequenced_worker_pool_unittest.cc
|
| diff --git a/base/threading/sequenced_worker_pool_unittest.cc b/base/threading/sequenced_worker_pool_unittest.cc
|
| index c1327318294f8bb5b5a10fbb2ec47b260019b6f8..5d0880c236fc2cc4b80674006c9e8e7027f9540e 100644
|
| --- a/base/threading/sequenced_worker_pool_unittest.cc
|
| +++ b/base/threading/sequenced_worker_pool_unittest.cc
|
| @@ -148,6 +148,17 @@ class TestTracker : public base::RefCountedThreadSafe<TestTracker> {
|
| FROM_HERE, reposting_task, SequencedWorkerPool::SKIP_ON_SHUTDOWN);
|
| }
|
|
|
| + // This task reposts itself back onto the SequencedWorkerPool before it
|
| + // finishes running.
|
| + void PostRepostingBlockingTask(
|
| + const scoped_refptr<SequencedWorkerPool>& pool,
|
| + const SequencedWorkerPool::SequenceToken& token) {
|
| + Closure reposting_task =
|
| + base::Bind(&TestTracker::PostRepostingBlockingTask, this, pool, token);
|
| + pool->PostSequencedWorkerTaskWithShutdownBehavior(token,
|
| + FROM_HERE, reposting_task, SequencedWorkerPool::BLOCK_SHUTDOWN);
|
| + }
|
| +
|
| // Waits until the given number of tasks have started executing.
|
| void WaitUntilTasksBlocked(size_t count) {
|
| {
|
| @@ -795,6 +806,26 @@ TEST_F(SequencedWorkerPoolTest, AvoidsDeadlockOnShutdown) {
|
| pool()->Shutdown();
|
| }
|
|
|
| +// Similar to the test AvoidsDeadlockOnShutdown, but there are now also
|
| +// sequenced, blocking tasks in the queue during shutdown.
|
| +TEST_F(SequencedWorkerPoolTest,
|
| + AvoidsDeadlockOnShutdownWithSequencedBlockingTasks) {
|
| + const std::string sequence_token_name("name");
|
| + for (int i = 0; i < 4; ++i) {
|
| + scoped_refptr<DestructionDeadlockChecker> checker(
|
| + new DestructionDeadlockChecker(pool()));
|
| + tracker()->PostRepostingTask(pool(), checker);
|
| +
|
| + SequencedWorkerPool::SequenceToken token1 =
|
| + pool()->GetNamedSequenceToken(sequence_token_name);
|
| + tracker()->PostRepostingBlockingTask(pool(), token1);
|
| + }
|
| +
|
| + // Shutting down the pool should destroy the DestructionDeadlockCheckers,
|
| + // which in turn should not deadlock in their destructors.
|
| + pool()->Shutdown();
|
| +}
|
| +
|
| // Verify that FlushForTesting works as intended.
|
| TEST_F(SequencedWorkerPoolTest, FlushForTesting) {
|
| // Should be fine to call on a new instance.
|
|
|