| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/threading/sequenced_worker_pool.h" | 5 #include "base/threading/sequenced_worker_pool.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 // PrepareToStartAdditionalThreadIfNecessary in the .cc file for more | 315 // PrepareToStartAdditionalThreadIfNecessary in the .cc file for more |
| 316 // details. | 316 // details. |
| 317 // | 317 // |
| 318 // It will post tasks to the queue with id -1. It also assumes this is the | 318 // It will post tasks to the queue with id -1. It also assumes this is the |
| 319 // first thing called in a test since it will clear the complete_sequence_. | 319 // first thing called in a test since it will clear the complete_sequence_. |
| 320 void EnsureAllWorkersCreated() { | 320 void EnsureAllWorkersCreated() { |
| 321 // Create a bunch of threads, all waiting. This will cause that may | 321 // Create a bunch of threads, all waiting. This will cause that may |
| 322 // workers to be created. | 322 // workers to be created. |
| 323 ThreadBlocker blocker; | 323 ThreadBlocker blocker; |
| 324 for (size_t i = 0; i < kNumWorkerThreads; i++) { | 324 for (size_t i = 0; i < kNumWorkerThreads; i++) { |
| 325 pool()->PostWorkerTask( | 325 pool()->PostTask(FROM_HERE, base::BindOnce(&TestTracker::BlockTask, |
| 326 FROM_HERE, | 326 tracker(), -1, &blocker)); |
| 327 base::BindOnce(&TestTracker::BlockTask, tracker(), -1, &blocker)); | |
| 328 } | 327 } |
| 329 tracker()->WaitUntilTasksBlocked(kNumWorkerThreads); | 328 tracker()->WaitUntilTasksBlocked(kNumWorkerThreads); |
| 330 | 329 |
| 331 // Now wake them up and wait until they're done. | 330 // Now wake them up and wait until they're done. |
| 332 blocker.Unblock(kNumWorkerThreads); | 331 blocker.Unblock(kNumWorkerThreads); |
| 333 tracker()->WaitUntilTasksComplete(kNumWorkerThreads); | 332 tracker()->WaitUntilTasksComplete(kNumWorkerThreads); |
| 334 | 333 |
| 335 // Clean up the task IDs we added. | 334 // Clean up the task IDs we added. |
| 336 tracker()->ClearCompleteSequence(); | 335 tracker()->ClearCompleteSequence(); |
| 337 } | 336 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 EXPECT_TRUE(token1.Equals(token1again)); | 445 EXPECT_TRUE(token1.Equals(token1again)); |
| 447 | 446 |
| 448 SequencedWorkerPool::SequenceToken token3again = | 447 SequencedWorkerPool::SequenceToken token3again = |
| 449 pool()->GetNamedSequenceToken(name3); | 448 pool()->GetNamedSequenceToken(name3); |
| 450 EXPECT_TRUE(token3.Equals(token3again)); | 449 EXPECT_TRUE(token3.Equals(token3again)); |
| 451 } | 450 } |
| 452 | 451 |
| 453 // Tests that posting a bunch of tasks (many more than the number of worker | 452 // Tests that posting a bunch of tasks (many more than the number of worker |
| 454 // threads) runs them all. | 453 // threads) runs them all. |
| 455 TEST_P(SequencedWorkerPoolTest, LotsOfTasks) { | 454 TEST_P(SequencedWorkerPoolTest, LotsOfTasks) { |
| 456 pool()->PostWorkerTask(FROM_HERE, | 455 pool()->PostTask(FROM_HERE, |
| 457 base::BindOnce(&TestTracker::SlowTask, tracker(), 0)); | 456 base::BindOnce(&TestTracker::SlowTask, tracker(), 0)); |
| 458 | 457 |
| 459 const size_t kNumTasks = 20; | 458 const size_t kNumTasks = 20; |
| 460 for (size_t i = 1; i < kNumTasks; i++) { | 459 for (size_t i = 1; i < kNumTasks; i++) { |
| 461 pool()->PostWorkerTask( | 460 pool()->PostTask(FROM_HERE, |
| 462 FROM_HERE, base::BindOnce(&TestTracker::FastTask, tracker(), i)); | 461 base::BindOnce(&TestTracker::FastTask, tracker(), i)); |
| 463 } | 462 } |
| 464 | 463 |
| 465 std::vector<int> result = tracker()->WaitUntilTasksComplete(kNumTasks); | 464 std::vector<int> result = tracker()->WaitUntilTasksComplete(kNumTasks); |
| 466 EXPECT_EQ(kNumTasks, result.size()); | 465 EXPECT_EQ(kNumTasks, result.size()); |
| 467 } | 466 } |
| 468 | 467 |
| 469 // Tests that posting a bunch of tasks (many more than the number of | 468 // Tests that posting a bunch of tasks (many more than the number of |
| 470 // worker threads) to two pools simultaneously runs them all twice. | 469 // worker threads) to two pools simultaneously runs them all twice. |
| 471 // This test is meant to shake out any concurrency issues between | 470 // This test is meant to shake out any concurrency issues between |
| 472 // pools (like histograms). | 471 // pools (like histograms). |
| 473 TEST_P(SequencedWorkerPoolTest, LotsOfTasksTwoPools) { | 472 TEST_P(SequencedWorkerPoolTest, LotsOfTasksTwoPools) { |
| 474 SequencedWorkerPoolOwner pool1(kNumWorkerThreads, "test1"); | 473 SequencedWorkerPoolOwner pool1(kNumWorkerThreads, "test1"); |
| 475 SequencedWorkerPoolOwner pool2(kNumWorkerThreads, "test2"); | 474 SequencedWorkerPoolOwner pool2(kNumWorkerThreads, "test2"); |
| 476 | 475 |
| 477 base::Closure slow_task = base::Bind(&TestTracker::SlowTask, tracker(), 0); | 476 base::Closure slow_task = base::Bind(&TestTracker::SlowTask, tracker(), 0); |
| 478 pool1.pool()->PostWorkerTask(FROM_HERE, slow_task); | 477 pool1.pool()->PostTask(FROM_HERE, slow_task); |
| 479 pool2.pool()->PostWorkerTask(FROM_HERE, slow_task); | 478 pool2.pool()->PostTask(FROM_HERE, slow_task); |
| 480 | 479 |
| 481 const size_t kNumTasks = 20; | 480 const size_t kNumTasks = 20; |
| 482 for (size_t i = 1; i < kNumTasks; i++) { | 481 for (size_t i = 1; i < kNumTasks; i++) { |
| 483 base::Closure fast_task = | 482 base::Closure fast_task = |
| 484 base::Bind(&TestTracker::FastTask, tracker(), i); | 483 base::Bind(&TestTracker::FastTask, tracker(), i); |
| 485 pool1.pool()->PostWorkerTask(FROM_HERE, fast_task); | 484 pool1.pool()->PostTask(FROM_HERE, fast_task); |
| 486 pool2.pool()->PostWorkerTask(FROM_HERE, fast_task); | 485 pool2.pool()->PostTask(FROM_HERE, fast_task); |
| 487 } | 486 } |
| 488 | 487 |
| 489 std::vector<int> result = | 488 std::vector<int> result = |
| 490 tracker()->WaitUntilTasksComplete(2*kNumTasks); | 489 tracker()->WaitUntilTasksComplete(2*kNumTasks); |
| 491 EXPECT_EQ(2 * kNumTasks, result.size()); | 490 EXPECT_EQ(2 * kNumTasks, result.size()); |
| 492 } | 491 } |
| 493 | 492 |
| 494 // Test that tasks with the same sequence token are executed in order but don't | 493 // Test that tasks with the same sequence token are executed in order but don't |
| 495 // affect other tasks. | 494 // affect other tasks. |
| 496 TEST_P(SequencedWorkerPoolTest, Sequence) { | 495 TEST_P(SequencedWorkerPoolTest, Sequence) { |
| 497 // Fill all the worker threads except one. | 496 // Fill all the worker threads except one. |
| 498 const size_t kNumBackgroundTasks = kNumWorkerThreads - 1; | 497 const size_t kNumBackgroundTasks = kNumWorkerThreads - 1; |
| 499 ThreadBlocker background_blocker; | 498 ThreadBlocker background_blocker; |
| 500 for (size_t i = 0; i < kNumBackgroundTasks; i++) { | 499 for (size_t i = 0; i < kNumBackgroundTasks; i++) { |
| 501 pool()->PostWorkerTask(FROM_HERE, | 500 pool()->PostTask(FROM_HERE, |
| 502 base::BindOnce(&TestTracker::BlockTask, tracker(), i, | 501 base::BindOnce(&TestTracker::BlockTask, tracker(), i, |
| 503 &background_blocker)); | 502 &background_blocker)); |
| 504 } | 503 } |
| 505 tracker()->WaitUntilTasksBlocked(kNumBackgroundTasks); | 504 tracker()->WaitUntilTasksBlocked(kNumBackgroundTasks); |
| 506 | 505 |
| 507 // Create two tasks with the same sequence token, one that will block on the | 506 // Create two tasks with the same sequence token, one that will block on the |
| 508 // event, and one which will just complete quickly when it's run. Since there | 507 // event, and one which will just complete quickly when it's run. Since there |
| 509 // is one worker thread free, the first task will start and then block, and | 508 // is one worker thread free, the first task will start and then block, and |
| 510 // the second task should be waiting. | 509 // the second task should be waiting. |
| 511 ThreadBlocker blocker; | 510 ThreadBlocker blocker; |
| 512 SequencedWorkerPool::SequenceToken token1 = pool()->GetSequenceToken(); | 511 SequencedWorkerPool::SequenceToken token1 = pool()->GetSequenceToken(); |
| 513 pool()->PostSequencedWorkerTask( | 512 pool()->PostSequencedWorkerTask( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 EXPECT_EQ(101, result[result.size() - 1]); | 551 EXPECT_EQ(101, result[result.size() - 1]); |
| 553 } | 552 } |
| 554 | 553 |
| 555 // Tests that any tasks posted after Shutdown are ignored. | 554 // Tests that any tasks posted after Shutdown are ignored. |
| 556 // Disabled for flakiness. See http://crbug.com/166451. | 555 // Disabled for flakiness. See http://crbug.com/166451. |
| 557 TEST_P(SequencedWorkerPoolTest, DISABLED_IgnoresAfterShutdown) { | 556 TEST_P(SequencedWorkerPoolTest, DISABLED_IgnoresAfterShutdown) { |
| 558 // Start tasks to take all the threads and block them. | 557 // Start tasks to take all the threads and block them. |
| 559 EnsureAllWorkersCreated(); | 558 EnsureAllWorkersCreated(); |
| 560 ThreadBlocker blocker; | 559 ThreadBlocker blocker; |
| 561 for (size_t i = 0; i < kNumWorkerThreads; i++) { | 560 for (size_t i = 0; i < kNumWorkerThreads; i++) { |
| 562 pool()->PostWorkerTask(FROM_HERE, base::BindOnce(&TestTracker::BlockTask, | 561 pool()->PostTask(FROM_HERE, base::BindOnce(&TestTracker::BlockTask, |
| 563 tracker(), i, &blocker)); | 562 tracker(), i, &blocker)); |
| 564 } | 563 } |
| 565 tracker()->WaitUntilTasksBlocked(kNumWorkerThreads); | 564 tracker()->WaitUntilTasksBlocked(kNumWorkerThreads); |
| 566 | 565 |
| 567 SetWillWaitForShutdownCallback( | 566 SetWillWaitForShutdownCallback( |
| 568 base::Bind(&EnsureTasksToCompleteCountAndUnblock, | 567 base::Bind(&EnsureTasksToCompleteCountAndUnblock, |
| 569 scoped_refptr<TestTracker>(tracker()), 0, | 568 scoped_refptr<TestTracker>(tracker()), 0, |
| 570 &blocker, kNumWorkerThreads)); | 569 &blocker, kNumWorkerThreads)); |
| 571 | 570 |
| 572 // Shutdown the worker pool. This should discard all non-blocking tasks. | 571 // Shutdown the worker pool. This should discard all non-blocking tasks. |
| 573 const int kMaxNewBlockingTasksAfterShutdown = 100; | 572 const int kMaxNewBlockingTasksAfterShutdown = 100; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 599 | 598 |
| 600 TEST_P(SequencedWorkerPoolTest, AllowsAfterShutdown) { | 599 TEST_P(SequencedWorkerPoolTest, AllowsAfterShutdown) { |
| 601 // Test that <n> new blocking tasks are allowed provided they're posted | 600 // Test that <n> new blocking tasks are allowed provided they're posted |
| 602 // by a running tasks. | 601 // by a running tasks. |
| 603 EnsureAllWorkersCreated(); | 602 EnsureAllWorkersCreated(); |
| 604 ThreadBlocker blocker; | 603 ThreadBlocker blocker; |
| 605 | 604 |
| 606 // Start tasks to take all the threads and block them. | 605 // Start tasks to take all the threads and block them. |
| 607 const int kNumBlockTasks = static_cast<int>(kNumWorkerThreads); | 606 const int kNumBlockTasks = static_cast<int>(kNumWorkerThreads); |
| 608 for (int i = 0; i < kNumBlockTasks; ++i) { | 607 for (int i = 0; i < kNumBlockTasks; ++i) { |
| 609 EXPECT_TRUE(pool()->PostWorkerTask( | 608 EXPECT_TRUE(pool()->PostTask( |
| 610 FROM_HERE, | 609 FROM_HERE, |
| 611 base::BindOnce(&TestTracker::BlockTask, tracker(), i, &blocker))); | 610 base::BindOnce(&TestTracker::BlockTask, tracker(), i, &blocker))); |
| 612 } | 611 } |
| 613 tracker()->WaitUntilTasksBlocked(kNumWorkerThreads); | 612 tracker()->WaitUntilTasksBlocked(kNumWorkerThreads); |
| 614 | 613 |
| 615 // Queue up shutdown blocking tasks behind those which will attempt to post | 614 // Queue up shutdown blocking tasks behind those which will attempt to post |
| 616 // additional tasks when run, PostAdditionalTasks attempts to post 3 | 615 // additional tasks when run, PostAdditionalTasks attempts to post 3 |
| 617 // new FastTasks, one for each shutdown_behavior. | 616 // new FastTasks, one for each shutdown_behavior. |
| 618 const int kNumQueuedTasks = static_cast<int>(kNumWorkerThreads); | 617 const int kNumQueuedTasks = static_cast<int>(kNumWorkerThreads); |
| 619 for (int i = 0; i < kNumQueuedTasks; ++i) { | 618 for (int i = 0; i < kNumQueuedTasks; ++i) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 // Tests that blocking tasks can still be posted during shutdown, as long as | 662 // Tests that blocking tasks can still be posted during shutdown, as long as |
| 664 // the task is not being posted within the context of a running task. | 663 // the task is not being posted within the context of a running task. |
| 665 TEST_P(SequencedWorkerPoolTest, | 664 TEST_P(SequencedWorkerPoolTest, |
| 666 AllowsBlockingTasksDuringShutdownOutsideOfRunningTask) { | 665 AllowsBlockingTasksDuringShutdownOutsideOfRunningTask) { |
| 667 EnsureAllWorkersCreated(); | 666 EnsureAllWorkersCreated(); |
| 668 ThreadBlocker blocker; | 667 ThreadBlocker blocker; |
| 669 | 668 |
| 670 // Start tasks to take all the threads and block them. | 669 // Start tasks to take all the threads and block them. |
| 671 const int kNumBlockTasks = static_cast<int>(kNumWorkerThreads); | 670 const int kNumBlockTasks = static_cast<int>(kNumWorkerThreads); |
| 672 for (int i = 0; i < kNumBlockTasks; ++i) { | 671 for (int i = 0; i < kNumBlockTasks; ++i) { |
| 673 EXPECT_TRUE(pool()->PostWorkerTask( | 672 EXPECT_TRUE(pool()->PostTask( |
| 674 FROM_HERE, | 673 FROM_HERE, |
| 675 base::BindOnce(&TestTracker::BlockTask, tracker(), i, &blocker))); | 674 base::BindOnce(&TestTracker::BlockTask, tracker(), i, &blocker))); |
| 676 } | 675 } |
| 677 tracker()->WaitUntilTasksBlocked(kNumWorkerThreads); | 676 tracker()->WaitUntilTasksBlocked(kNumWorkerThreads); |
| 678 | 677 |
| 679 constexpr int kNumNewBlockingTasksToAllow = 1; | 678 constexpr int kNumNewBlockingTasksToAllow = 1; |
| 680 | 679 |
| 681 if (RedirectedToTaskScheduler()) { | 680 if (RedirectedToTaskScheduler()) { |
| 682 // When redirection to TaskScheduler is enabled, | 681 // When redirection to TaskScheduler is enabled, |
| 683 // SequencedWorkerPool::Shutdown() sets the number of additional | 682 // SequencedWorkerPool::Shutdown() sets the number of additional |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 // CONTINUE_ON_SHUTDOWN tasks and runs BLOCK_SHUTDOWN tasks. However, since it | 718 // CONTINUE_ON_SHUTDOWN tasks and runs BLOCK_SHUTDOWN tasks. However, since it |
| 720 // doesn't provide a way to run a callback from inside its Shutdown() method, | 719 // doesn't provide a way to run a callback from inside its Shutdown() method, |
| 721 // it would be hard to make this test work with redirection enabled. | 720 // it would be hard to make this test work with redirection enabled. |
| 722 if (RedirectedToTaskScheduler()) | 721 if (RedirectedToTaskScheduler()) |
| 723 return; | 722 return; |
| 724 | 723 |
| 725 // Start tasks to take all the threads and block them. | 724 // Start tasks to take all the threads and block them. |
| 726 EnsureAllWorkersCreated(); | 725 EnsureAllWorkersCreated(); |
| 727 ThreadBlocker blocker; | 726 ThreadBlocker blocker; |
| 728 for (size_t i = 0; i < kNumWorkerThreads; i++) { | 727 for (size_t i = 0; i < kNumWorkerThreads; i++) { |
| 729 pool()->PostWorkerTask(FROM_HERE, base::BindOnce(&TestTracker::BlockTask, | 728 pool()->PostTask(FROM_HERE, base::BindOnce(&TestTracker::BlockTask, |
| 730 tracker(), i, &blocker)); | 729 tracker(), i, &blocker)); |
| 731 } | 730 } |
| 732 tracker()->WaitUntilTasksBlocked(kNumWorkerThreads); | 731 tracker()->WaitUntilTasksBlocked(kNumWorkerThreads); |
| 733 | 732 |
| 734 // Create some tasks with different shutdown modes. | 733 // Create some tasks with different shutdown modes. |
| 735 pool()->PostWorkerTaskWithShutdownBehavior( | 734 pool()->PostWorkerTaskWithShutdownBehavior( |
| 736 FROM_HERE, base::BindOnce(&TestTracker::FastTask, tracker(), 100), | 735 FROM_HERE, base::BindOnce(&TestTracker::FastTask, tracker(), 100), |
| 737 SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 736 SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| 738 pool()->PostWorkerTaskWithShutdownBehavior( | 737 pool()->PostWorkerTaskWithShutdownBehavior( |
| 739 FROM_HERE, base::BindOnce(&TestTracker::FastTask, tracker(), 101), | 738 FROM_HERE, base::BindOnce(&TestTracker::FastTask, tracker(), 101), |
| 740 SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 739 SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 // Verify that FlushForTesting works as intended. | 986 // Verify that FlushForTesting works as intended. |
| 988 TEST_P(SequencedWorkerPoolTest, FlushForTesting) { | 987 TEST_P(SequencedWorkerPoolTest, FlushForTesting) { |
| 989 // Should be fine to call on a new instance. | 988 // Should be fine to call on a new instance. |
| 990 pool()->FlushForTesting(); | 989 pool()->FlushForTesting(); |
| 991 | 990 |
| 992 // Queue up a bunch of work, including a long delayed task and | 991 // Queue up a bunch of work, including a long delayed task and |
| 993 // a task that produces additional tasks as an artifact. | 992 // a task that produces additional tasks as an artifact. |
| 994 pool()->PostDelayedTask(FROM_HERE, | 993 pool()->PostDelayedTask(FROM_HERE, |
| 995 base::BindOnce(&TestTracker::FastTask, tracker(), 0), | 994 base::BindOnce(&TestTracker::FastTask, tracker(), 0), |
| 996 TimeDelta::FromMinutes(5)); | 995 TimeDelta::FromMinutes(5)); |
| 997 pool()->PostWorkerTask(FROM_HERE, | 996 pool()->PostTask(FROM_HERE, |
| 998 base::BindOnce(&TestTracker::SlowTask, tracker(), 0)); | 997 base::BindOnce(&TestTracker::SlowTask, tracker(), 0)); |
| 999 const size_t kNumFastTasks = 20; | 998 const size_t kNumFastTasks = 20; |
| 1000 for (size_t i = 0; i < kNumFastTasks; i++) { | 999 for (size_t i = 0; i < kNumFastTasks; i++) { |
| 1001 pool()->PostWorkerTask( | 1000 pool()->PostTask(FROM_HERE, |
| 1002 FROM_HERE, base::BindOnce(&TestTracker::FastTask, tracker(), 0)); | 1001 base::BindOnce(&TestTracker::FastTask, tracker(), 0)); |
| 1003 } | 1002 } |
| 1004 pool()->PostWorkerTask( | 1003 pool()->PostTask( |
| 1005 FROM_HERE, base::BindOnce(&TestTracker::PostAdditionalTasks, tracker(), 0, | 1004 FROM_HERE, base::BindOnce(&TestTracker::PostAdditionalTasks, tracker(), 0, |
| 1006 base::RetainedRef(pool()), true)); | 1005 base::RetainedRef(pool()), true)); |
| 1007 | 1006 |
| 1008 // We expect all except the delayed task to have been run. We verify all | 1007 // We expect all except the delayed task to have been run. We verify all |
| 1009 // closures have been deleted by looking at the refcount of the | 1008 // closures have been deleted by looking at the refcount of the |
| 1010 // tracker. | 1009 // tracker. |
| 1011 EXPECT_FALSE(tracker()->HasOneRef()); | 1010 EXPECT_FALSE(tracker()->HasOneRef()); |
| 1012 pool()->FlushForTesting(); | 1011 pool()->FlushForTesting(); |
| 1013 EXPECT_EQ(1 + kNumFastTasks + 1 + 3, tracker()->GetTasksCompletedCount()); | 1012 EXPECT_EQ(1 + kNumFastTasks + 1 + 3, tracker()->GetTasksCompletedCount()); |
| 1014 // TaskScheduler deletes unexecuted delayed tasks as part of ~TaskScheduler() | 1013 // TaskScheduler deletes unexecuted delayed tasks as part of ~TaskScheduler() |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 | 1070 |
| 1072 SequencedWorkerPool::SequenceToken token1 = pool()->GetSequenceToken(); | 1071 SequencedWorkerPool::SequenceToken token1 = pool()->GetSequenceToken(); |
| 1073 SequencedWorkerPool::SequenceToken token2 = pool()->GetSequenceToken(); | 1072 SequencedWorkerPool::SequenceToken token2 = pool()->GetSequenceToken(); |
| 1074 pool()->PostSequencedWorkerTask( | 1073 pool()->PostSequencedWorkerTask( |
| 1075 token1, FROM_HERE, | 1074 token1, FROM_HERE, |
| 1076 base::BindOnce(&CheckWorkerPoolAndSequenceToken, pool(), token1)); | 1075 base::BindOnce(&CheckWorkerPoolAndSequenceToken, pool(), token1)); |
| 1077 pool()->PostSequencedWorkerTask( | 1076 pool()->PostSequencedWorkerTask( |
| 1078 token2, FROM_HERE, | 1077 token2, FROM_HERE, |
| 1079 base::BindOnce(&CheckWorkerPoolAndSequenceToken, pool(), token2)); | 1078 base::BindOnce(&CheckWorkerPoolAndSequenceToken, pool(), token2)); |
| 1080 | 1079 |
| 1081 pool()->PostWorkerTask( | 1080 pool()->PostTask(FROM_HERE, |
| 1082 FROM_HERE, base::BindOnce(&CheckWorkerPoolAndSequenceToken, pool(), | 1081 base::BindOnce(&CheckWorkerPoolAndSequenceToken, pool(), |
| 1083 SequencedWorkerPool::SequenceToken())); | 1082 SequencedWorkerPool::SequenceToken())); |
| 1084 | 1083 |
| 1085 pool()->FlushForTesting(); | 1084 pool()->FlushForTesting(); |
| 1086 } | 1085 } |
| 1087 | 1086 |
| 1088 TEST_P(SequencedWorkerPoolTest, ShutsDownCleanWithContinueOnShutdown) { | 1087 TEST_P(SequencedWorkerPoolTest, ShutsDownCleanWithContinueOnShutdown) { |
| 1089 scoped_refptr<SequencedTaskRunner> task_runner = | 1088 scoped_refptr<SequencedTaskRunner> task_runner = |
| 1090 pool()->GetSequencedTaskRunnerWithShutdownBehavior( | 1089 pool()->GetSequencedTaskRunnerWithShutdownBehavior( |
| 1091 pool()->GetSequenceToken(), | 1090 pool()->GetSequenceToken(), |
| 1092 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 1091 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| 1093 | 1092 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 SequencedWorkerPoolSequencedTaskRunner, SequencedTaskRunnerTest, | 1222 SequencedWorkerPoolSequencedTaskRunner, SequencedTaskRunnerTest, |
| 1224 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); | 1223 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); |
| 1225 INSTANTIATE_TYPED_TEST_CASE_P( | 1224 INSTANTIATE_TYPED_TEST_CASE_P( |
| 1226 SequencedWorkerPoolSequencedTaskRunner, | 1225 SequencedWorkerPoolSequencedTaskRunner, |
| 1227 SequencedTaskRunnerDelayedTest, | 1226 SequencedTaskRunnerDelayedTest, |
| 1228 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); | 1227 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); |
| 1229 | 1228 |
| 1230 } // namespace | 1229 } // namespace |
| 1231 | 1230 |
| 1232 } // namespace base | 1231 } // namespace base |
| OLD | NEW |