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

Unified Diff: base/threading/sequenced_worker_pool_unittest.cc

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « base/threading/sequenced_worker_pool.cc ('k') | base/time/time.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « base/threading/sequenced_worker_pool.cc ('k') | base/time/time.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698