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