| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // | 133 // |
| 134 // Note that this class is RefCountedThreadSafe (inherited from TaskRunner). | 134 // Note that this class is RefCountedThreadSafe (inherited from TaskRunner). |
| 135 class SequencedWorkerPoolTaskRunner : public TaskRunner { | 135 class SequencedWorkerPoolTaskRunner : public TaskRunner { |
| 136 public: | 136 public: |
| 137 SequencedWorkerPoolTaskRunner( | 137 SequencedWorkerPoolTaskRunner( |
| 138 scoped_refptr<SequencedWorkerPool> pool, | 138 scoped_refptr<SequencedWorkerPool> pool, |
| 139 SequencedWorkerPool::WorkerShutdown shutdown_behavior); | 139 SequencedWorkerPool::WorkerShutdown shutdown_behavior); |
| 140 | 140 |
| 141 // TaskRunner implementation | 141 // TaskRunner implementation |
| 142 bool PostDelayedTask(const tracked_objects::Location& from_here, | 142 bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 143 const Closure& task, | 143 Closure task, |
| 144 TimeDelta delay) override; | 144 TimeDelta delay) override; |
| 145 bool RunsTasksOnCurrentThread() const override; | 145 bool RunsTasksOnCurrentThread() const override; |
| 146 | 146 |
| 147 private: | 147 private: |
| 148 ~SequencedWorkerPoolTaskRunner() override; | 148 ~SequencedWorkerPoolTaskRunner() override; |
| 149 | 149 |
| 150 const scoped_refptr<SequencedWorkerPool> pool_; | 150 const scoped_refptr<SequencedWorkerPool> pool_; |
| 151 | 151 |
| 152 const SequencedWorkerPool::WorkerShutdown shutdown_behavior_; | 152 const SequencedWorkerPool::WorkerShutdown shutdown_behavior_; |
| 153 | 153 |
| 154 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPoolTaskRunner); | 154 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPoolTaskRunner); |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 SequencedWorkerPoolTaskRunner::SequencedWorkerPoolTaskRunner( | 157 SequencedWorkerPoolTaskRunner::SequencedWorkerPoolTaskRunner( |
| 158 scoped_refptr<SequencedWorkerPool> pool, | 158 scoped_refptr<SequencedWorkerPool> pool, |
| 159 SequencedWorkerPool::WorkerShutdown shutdown_behavior) | 159 SequencedWorkerPool::WorkerShutdown shutdown_behavior) |
| 160 : pool_(std::move(pool)), shutdown_behavior_(shutdown_behavior) {} | 160 : pool_(std::move(pool)), shutdown_behavior_(shutdown_behavior) {} |
| 161 | 161 |
| 162 SequencedWorkerPoolTaskRunner::~SequencedWorkerPoolTaskRunner() { | 162 SequencedWorkerPoolTaskRunner::~SequencedWorkerPoolTaskRunner() { |
| 163 } | 163 } |
| 164 | 164 |
| 165 bool SequencedWorkerPoolTaskRunner::PostDelayedTask( | 165 bool SequencedWorkerPoolTaskRunner::PostDelayedTask( |
| 166 const tracked_objects::Location& from_here, | 166 const tracked_objects::Location& from_here, |
| 167 const Closure& task, | 167 Closure task, |
| 168 TimeDelta delay) { | 168 TimeDelta delay) { |
| 169 if (delay.is_zero()) { | 169 if (delay.is_zero()) { |
| 170 return pool_->PostWorkerTaskWithShutdownBehavior( | 170 return pool_->PostWorkerTaskWithShutdownBehavior(from_here, std::move(task), |
| 171 from_here, task, shutdown_behavior_); | 171 shutdown_behavior_); |
| 172 } | 172 } |
| 173 return pool_->PostDelayedWorkerTask(from_here, task, delay); | 173 return pool_->PostDelayedWorkerTask(from_here, std::move(task), delay); |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool SequencedWorkerPoolTaskRunner::RunsTasksOnCurrentThread() const { | 176 bool SequencedWorkerPoolTaskRunner::RunsTasksOnCurrentThread() const { |
| 177 return pool_->RunsTasksOnCurrentThread(); | 177 return pool_->RunsTasksOnCurrentThread(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace | 180 } // namespace |
| 181 | 181 |
| 182 // SequencedWorkerPool::PoolSequencedTaskRunner ------------------------------ | 182 // SequencedWorkerPool::PoolSequencedTaskRunner ------------------------------ |
| 183 // A SequencedTaskRunner which posts tasks to a SequencedWorkerPool with a | 183 // A SequencedTaskRunner which posts tasks to a SequencedWorkerPool with a |
| 184 // fixed sequence token. | 184 // fixed sequence token. |
| 185 // | 185 // |
| 186 // Note that this class is RefCountedThreadSafe (inherited from TaskRunner). | 186 // Note that this class is RefCountedThreadSafe (inherited from TaskRunner). |
| 187 class SequencedWorkerPool::PoolSequencedTaskRunner | 187 class SequencedWorkerPool::PoolSequencedTaskRunner |
| 188 : public SequencedTaskRunner { | 188 : public SequencedTaskRunner { |
| 189 public: | 189 public: |
| 190 PoolSequencedTaskRunner( | 190 PoolSequencedTaskRunner( |
| 191 scoped_refptr<SequencedWorkerPool> pool, | 191 scoped_refptr<SequencedWorkerPool> pool, |
| 192 SequencedWorkerPool::SequenceToken token, | 192 SequencedWorkerPool::SequenceToken token, |
| 193 SequencedWorkerPool::WorkerShutdown shutdown_behavior); | 193 SequencedWorkerPool::WorkerShutdown shutdown_behavior); |
| 194 | 194 |
| 195 // TaskRunner implementation | 195 // TaskRunner implementation |
| 196 bool PostDelayedTask(const tracked_objects::Location& from_here, | 196 bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 197 const Closure& task, | 197 Closure task, |
| 198 TimeDelta delay) override; | 198 TimeDelta delay) override; |
| 199 bool RunsTasksOnCurrentThread() const override; | 199 bool RunsTasksOnCurrentThread() const override; |
| 200 | 200 |
| 201 // SequencedTaskRunner implementation | 201 // SequencedTaskRunner implementation |
| 202 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 202 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
| 203 const Closure& task, | 203 Closure task, |
| 204 TimeDelta delay) override; | 204 TimeDelta delay) override; |
| 205 | 205 |
| 206 private: | 206 private: |
| 207 ~PoolSequencedTaskRunner() override; | 207 ~PoolSequencedTaskRunner() override; |
| 208 | 208 |
| 209 const scoped_refptr<SequencedWorkerPool> pool_; | 209 const scoped_refptr<SequencedWorkerPool> pool_; |
| 210 | 210 |
| 211 const SequencedWorkerPool::SequenceToken token_; | 211 const SequencedWorkerPool::SequenceToken token_; |
| 212 | 212 |
| 213 const SequencedWorkerPool::WorkerShutdown shutdown_behavior_; | 213 const SequencedWorkerPool::WorkerShutdown shutdown_behavior_; |
| 214 | 214 |
| 215 DISALLOW_COPY_AND_ASSIGN(PoolSequencedTaskRunner); | 215 DISALLOW_COPY_AND_ASSIGN(PoolSequencedTaskRunner); |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 SequencedWorkerPool::PoolSequencedTaskRunner:: | 218 SequencedWorkerPool::PoolSequencedTaskRunner:: |
| 219 PoolSequencedTaskRunner( | 219 PoolSequencedTaskRunner( |
| 220 scoped_refptr<SequencedWorkerPool> pool, | 220 scoped_refptr<SequencedWorkerPool> pool, |
| 221 SequencedWorkerPool::SequenceToken token, | 221 SequencedWorkerPool::SequenceToken token, |
| 222 SequencedWorkerPool::WorkerShutdown shutdown_behavior) | 222 SequencedWorkerPool::WorkerShutdown shutdown_behavior) |
| 223 : pool_(std::move(pool)), | 223 : pool_(std::move(pool)), |
| 224 token_(token), | 224 token_(token), |
| 225 shutdown_behavior_(shutdown_behavior) {} | 225 shutdown_behavior_(shutdown_behavior) {} |
| 226 | 226 |
| 227 SequencedWorkerPool::PoolSequencedTaskRunner:: | 227 SequencedWorkerPool::PoolSequencedTaskRunner:: |
| 228 ~PoolSequencedTaskRunner() = default; | 228 ~PoolSequencedTaskRunner() = default; |
| 229 | 229 |
| 230 bool SequencedWorkerPool::PoolSequencedTaskRunner:: | 230 bool SequencedWorkerPool::PoolSequencedTaskRunner::PostDelayedTask( |
| 231 PostDelayedTask(const tracked_objects::Location& from_here, | 231 const tracked_objects::Location& from_here, |
| 232 const Closure& task, | 232 Closure task, |
| 233 TimeDelta delay) { | 233 TimeDelta delay) { |
| 234 if (delay.is_zero()) { | 234 if (delay.is_zero()) { |
| 235 return pool_->PostSequencedWorkerTaskWithShutdownBehavior( | 235 return pool_->PostSequencedWorkerTaskWithShutdownBehavior( |
| 236 token_, from_here, task, shutdown_behavior_); | 236 token_, from_here, std::move(task), shutdown_behavior_); |
| 237 } | 237 } |
| 238 return pool_->PostDelayedSequencedWorkerTask(token_, from_here, task, delay); | 238 return pool_->PostDelayedSequencedWorkerTask(token_, from_here, |
| 239 std::move(task), delay); |
| 239 } | 240 } |
| 240 | 241 |
| 241 bool SequencedWorkerPool::PoolSequencedTaskRunner:: | 242 bool SequencedWorkerPool::PoolSequencedTaskRunner:: |
| 242 RunsTasksOnCurrentThread() const { | 243 RunsTasksOnCurrentThread() const { |
| 243 return pool_->IsRunningSequenceOnCurrentThread(token_); | 244 return pool_->IsRunningSequenceOnCurrentThread(token_); |
| 244 } | 245 } |
| 245 | 246 |
| 246 bool SequencedWorkerPool::PoolSequencedTaskRunner:: | 247 bool SequencedWorkerPool::PoolSequencedTaskRunner::PostNonNestableDelayedTask( |
| 247 PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 248 const tracked_objects::Location& from_here, |
| 248 const Closure& task, | 249 Closure task, |
| 249 TimeDelta delay) { | 250 TimeDelta delay) { |
| 250 // There's no way to run nested tasks, so simply forward to | 251 // There's no way to run nested tasks, so simply forward to |
| 251 // PostDelayedTask. | 252 // PostDelayedTask. |
| 252 return PostDelayedTask(from_here, task, delay); | 253 return PostDelayedTask(from_here, std::move(task), delay); |
| 253 } | 254 } |
| 254 | 255 |
| 255 // Worker --------------------------------------------------------------------- | 256 // Worker --------------------------------------------------------------------- |
| 256 | 257 |
| 257 class SequencedWorkerPool::Worker : public SimpleThread { | 258 class SequencedWorkerPool::Worker : public SimpleThread { |
| 258 public: | 259 public: |
| 259 // Hold a (cyclic) ref to |worker_pool|, since we want to keep it | 260 // Hold a (cyclic) ref to |worker_pool|, since we want to keep it |
| 260 // around as long as we are running. | 261 // around as long as we are running. |
| 261 Worker(scoped_refptr<SequencedWorkerPool> worker_pool, | 262 Worker(scoped_refptr<SequencedWorkerPool> worker_pool, |
| 262 int thread_number, | 263 int thread_number, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 342 |
| 342 SequenceToken GetNamedSequenceToken(const std::string& name); | 343 SequenceToken GetNamedSequenceToken(const std::string& name); |
| 343 | 344 |
| 344 // This function accepts a name and an ID. If the name is null, the | 345 // This function accepts a name and an ID. If the name is null, the |
| 345 // token ID is used. This allows us to implement the optional name lookup | 346 // token ID is used. This allows us to implement the optional name lookup |
| 346 // from a single function without having to enter the lock a separate time. | 347 // from a single function without having to enter the lock a separate time. |
| 347 bool PostTask(const std::string* optional_token_name, | 348 bool PostTask(const std::string* optional_token_name, |
| 348 SequenceToken sequence_token, | 349 SequenceToken sequence_token, |
| 349 WorkerShutdown shutdown_behavior, | 350 WorkerShutdown shutdown_behavior, |
| 350 const tracked_objects::Location& from_here, | 351 const tracked_objects::Location& from_here, |
| 351 const Closure& task, | 352 Closure task, |
| 352 TimeDelta delay); | 353 TimeDelta delay); |
| 353 | 354 |
| 354 bool RunsTasksOnCurrentThread() const; | 355 bool RunsTasksOnCurrentThread() const; |
| 355 | 356 |
| 356 bool IsRunningSequenceOnCurrentThread(SequenceToken sequence_token) const; | 357 bool IsRunningSequenceOnCurrentThread(SequenceToken sequence_token) const; |
| 357 | 358 |
| 358 void CleanupForTesting(); | 359 void CleanupForTesting(); |
| 359 | 360 |
| 360 void SignalHasWorkForTesting(); | 361 void SignalHasWorkForTesting(); |
| 361 | 362 |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 SequencedWorkerPool::Inner::GetNamedSequenceToken(const std::string& name) { | 686 SequencedWorkerPool::Inner::GetNamedSequenceToken(const std::string& name) { |
| 686 AutoLock lock(lock_); | 687 AutoLock lock(lock_); |
| 687 return SequenceToken(LockedGetNamedTokenID(name)); | 688 return SequenceToken(LockedGetNamedTokenID(name)); |
| 688 } | 689 } |
| 689 | 690 |
| 690 bool SequencedWorkerPool::Inner::PostTask( | 691 bool SequencedWorkerPool::Inner::PostTask( |
| 691 const std::string* optional_token_name, | 692 const std::string* optional_token_name, |
| 692 SequenceToken sequence_token, | 693 SequenceToken sequence_token, |
| 693 WorkerShutdown shutdown_behavior, | 694 WorkerShutdown shutdown_behavior, |
| 694 const tracked_objects::Location& from_here, | 695 const tracked_objects::Location& from_here, |
| 695 const Closure& task, | 696 Closure task, |
| 696 TimeDelta delay) { | 697 TimeDelta delay) { |
| 697 // TODO(fdoray): Uncomment this DCHECK. It is initially commented to avoid a | 698 // TODO(fdoray): Uncomment this DCHECK. It is initially commented to avoid a |
| 698 // revert of the CL that adds debug::DumpWithoutCrashing() if it fails on the | 699 // revert of the CL that adds debug::DumpWithoutCrashing() if it fails on the |
| 699 // waterfall. https://crbug.com/622400 | 700 // waterfall. https://crbug.com/622400 |
| 700 // DCHECK_NE(AllPoolsState::POST_TASK_DISABLED, g_all_pools_state); | 701 // DCHECK_NE(AllPoolsState::POST_TASK_DISABLED, g_all_pools_state); |
| 701 if (g_all_pools_state == AllPoolsState::POST_TASK_DISABLED) | 702 if (g_all_pools_state == AllPoolsState::POST_TASK_DISABLED) |
| 702 debug::DumpWithoutCrashing(); | 703 debug::DumpWithoutCrashing(); |
| 703 | 704 |
| 704 DCHECK(delay.is_zero() || shutdown_behavior == SKIP_ON_SHUTDOWN); | 705 DCHECK(delay.is_zero() || shutdown_behavior == SKIP_ON_SHUTDOWN); |
| 705 SequencedTask sequenced(from_here); | 706 SequencedTask sequenced(from_here); |
| 706 sequenced.sequence_token_id = sequence_token.id_; | 707 sequenced.sequence_token_id = sequence_token.id_; |
| 707 sequenced.shutdown_behavior = shutdown_behavior; | 708 sequenced.shutdown_behavior = shutdown_behavior; |
| 708 sequenced.posted_from = from_here; | 709 sequenced.posted_from = from_here; |
| 709 sequenced.task = | 710 sequenced.task = shutdown_behavior == BLOCK_SHUTDOWN |
| 710 shutdown_behavior == BLOCK_SHUTDOWN ? | 711 ? base::MakeCriticalClosure(std::move(task)) |
| 711 base::MakeCriticalClosure(task) : task; | 712 : std::move(task); |
| 712 sequenced.time_to_run = TimeTicks::Now() + delay; | 713 sequenced.time_to_run = TimeTicks::Now() + delay; |
| 713 | 714 |
| 714 int create_thread_id = 0; | 715 int create_thread_id = 0; |
| 715 { | 716 { |
| 716 AutoLock lock(lock_); | 717 AutoLock lock(lock_); |
| 717 | 718 |
| 718 if (shutdown_called_) { | 719 if (shutdown_called_) { |
| 719 // Don't allow a new task to be posted if it doesn't block shutdown. | 720 // Don't allow a new task to be posted if it doesn't block shutdown. |
| 720 if (shutdown_behavior != BLOCK_SHUTDOWN) | 721 if (shutdown_behavior != BLOCK_SHUTDOWN) |
| 721 return false; | 722 return false; |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 | 1012 |
| 1012 // Complete thread creation outside the lock if necessary. | 1013 // Complete thread creation outside the lock if necessary. |
| 1013 if (new_thread_id) | 1014 if (new_thread_id) |
| 1014 FinishStartingAdditionalThread(new_thread_id); | 1015 FinishStartingAdditionalThread(new_thread_id); |
| 1015 | 1016 |
| 1016 this_worker->set_running_task_info( | 1017 this_worker->set_running_task_info( |
| 1017 SequenceToken(task.sequence_token_id), task.shutdown_behavior); | 1018 SequenceToken(task.sequence_token_id), task.shutdown_behavior); |
| 1018 | 1019 |
| 1019 tracked_objects::TaskStopwatch stopwatch; | 1020 tracked_objects::TaskStopwatch stopwatch; |
| 1020 stopwatch.Start(); | 1021 stopwatch.Start(); |
| 1021 task.task.Run(); | 1022 std::move(task.task).Run(); |
| 1022 stopwatch.Stop(); | 1023 stopwatch.Stop(); |
| 1023 | 1024 |
| 1024 tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking( | 1025 tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking( |
| 1025 task, stopwatch); | 1026 task, stopwatch); |
| 1026 | 1027 |
| 1027 // Make sure our task is erased outside the lock for the | 1028 // Make sure our task is erased outside the lock for the |
| 1028 // same reason we do this with delete_these_oustide_lock. | 1029 // same reason we do this with delete_these_oustide_lock. |
| 1029 // Also, do it before calling reset_running_task_info() so | 1030 // Also, do it before calling reset_running_task_info() so |
| 1030 // that sequence-checking from within the task's destructor | 1031 // that sequence-checking from within the task's destructor |
| 1031 // still works. | 1032 // still works. |
| 1032 task.task = Closure(); | 1033 DCHECK(!task.task); |
| 1033 | 1034 |
| 1034 this_worker->reset_running_task_info(); | 1035 this_worker->reset_running_task_info(); |
| 1035 } | 1036 } |
| 1036 DidRunWorkerTask(task); // Must be done inside the lock. | 1037 DidRunWorkerTask(task); // Must be done inside the lock. |
| 1037 } else if (cleanup_state_ == CLEANUP_RUNNING) { | 1038 } else if (cleanup_state_ == CLEANUP_RUNNING) { |
| 1038 switch (status) { | 1039 switch (status) { |
| 1039 case GET_WORK_WAIT: { | 1040 case GET_WORK_WAIT: { |
| 1040 AutoUnlock unlock(lock_); | 1041 AutoUnlock unlock(lock_); |
| 1041 DeleteWithoutLock(&delete_these_outside_lock, this_worker); | 1042 DeleteWithoutLock(&delete_these_outside_lock, this_worker); |
| 1042 } | 1043 } |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 } | 1526 } |
| 1526 | 1527 |
| 1527 scoped_refptr<TaskRunner> | 1528 scoped_refptr<TaskRunner> |
| 1528 SequencedWorkerPool::GetTaskRunnerWithShutdownBehavior( | 1529 SequencedWorkerPool::GetTaskRunnerWithShutdownBehavior( |
| 1529 WorkerShutdown shutdown_behavior) { | 1530 WorkerShutdown shutdown_behavior) { |
| 1530 return new SequencedWorkerPoolTaskRunner(this, shutdown_behavior); | 1531 return new SequencedWorkerPoolTaskRunner(this, shutdown_behavior); |
| 1531 } | 1532 } |
| 1532 | 1533 |
| 1533 bool SequencedWorkerPool::PostWorkerTask( | 1534 bool SequencedWorkerPool::PostWorkerTask( |
| 1534 const tracked_objects::Location& from_here, | 1535 const tracked_objects::Location& from_here, |
| 1535 const Closure& task) { | 1536 Closure task) { |
| 1536 return inner_->PostTask(NULL, SequenceToken(), BLOCK_SHUTDOWN, | 1537 return inner_->PostTask(NULL, SequenceToken(), BLOCK_SHUTDOWN, from_here, |
| 1537 from_here, task, TimeDelta()); | 1538 std::move(task), TimeDelta()); |
| 1538 } | 1539 } |
| 1539 | 1540 |
| 1540 bool SequencedWorkerPool::PostDelayedWorkerTask( | 1541 bool SequencedWorkerPool::PostDelayedWorkerTask( |
| 1541 const tracked_objects::Location& from_here, | 1542 const tracked_objects::Location& from_here, |
| 1542 const Closure& task, | 1543 Closure task, |
| 1543 TimeDelta delay) { | 1544 TimeDelta delay) { |
| 1544 WorkerShutdown shutdown_behavior = | 1545 WorkerShutdown shutdown_behavior = |
| 1545 delay.is_zero() ? BLOCK_SHUTDOWN : SKIP_ON_SHUTDOWN; | 1546 delay.is_zero() ? BLOCK_SHUTDOWN : SKIP_ON_SHUTDOWN; |
| 1546 return inner_->PostTask(NULL, SequenceToken(), shutdown_behavior, | 1547 return inner_->PostTask(NULL, SequenceToken(), shutdown_behavior, from_here, |
| 1547 from_here, task, delay); | 1548 std::move(task), delay); |
| 1548 } | 1549 } |
| 1549 | 1550 |
| 1550 bool SequencedWorkerPool::PostWorkerTaskWithShutdownBehavior( | 1551 bool SequencedWorkerPool::PostWorkerTaskWithShutdownBehavior( |
| 1551 const tracked_objects::Location& from_here, | 1552 const tracked_objects::Location& from_here, |
| 1552 const Closure& task, | 1553 Closure task, |
| 1553 WorkerShutdown shutdown_behavior) { | 1554 WorkerShutdown shutdown_behavior) { |
| 1554 return inner_->PostTask(NULL, SequenceToken(), shutdown_behavior, | 1555 return inner_->PostTask(NULL, SequenceToken(), shutdown_behavior, from_here, |
| 1555 from_here, task, TimeDelta()); | 1556 std::move(task), TimeDelta()); |
| 1556 } | 1557 } |
| 1557 | 1558 |
| 1558 bool SequencedWorkerPool::PostSequencedWorkerTask( | 1559 bool SequencedWorkerPool::PostSequencedWorkerTask( |
| 1559 SequenceToken sequence_token, | 1560 SequenceToken sequence_token, |
| 1560 const tracked_objects::Location& from_here, | 1561 const tracked_objects::Location& from_here, |
| 1561 const Closure& task) { | 1562 Closure task) { |
| 1562 return inner_->PostTask(NULL, sequence_token, BLOCK_SHUTDOWN, | 1563 return inner_->PostTask(NULL, sequence_token, BLOCK_SHUTDOWN, from_here, |
| 1563 from_here, task, TimeDelta()); | 1564 std::move(task), TimeDelta()); |
| 1564 } | 1565 } |
| 1565 | 1566 |
| 1566 bool SequencedWorkerPool::PostDelayedSequencedWorkerTask( | 1567 bool SequencedWorkerPool::PostDelayedSequencedWorkerTask( |
| 1567 SequenceToken sequence_token, | 1568 SequenceToken sequence_token, |
| 1568 const tracked_objects::Location& from_here, | 1569 const tracked_objects::Location& from_here, |
| 1569 const Closure& task, | 1570 Closure task, |
| 1570 TimeDelta delay) { | 1571 TimeDelta delay) { |
| 1571 WorkerShutdown shutdown_behavior = | 1572 WorkerShutdown shutdown_behavior = |
| 1572 delay.is_zero() ? BLOCK_SHUTDOWN : SKIP_ON_SHUTDOWN; | 1573 delay.is_zero() ? BLOCK_SHUTDOWN : SKIP_ON_SHUTDOWN; |
| 1573 return inner_->PostTask(NULL, sequence_token, shutdown_behavior, | 1574 return inner_->PostTask(NULL, sequence_token, shutdown_behavior, from_here, |
| 1574 from_here, task, delay); | 1575 std::move(task), delay); |
| 1575 } | 1576 } |
| 1576 | 1577 |
| 1577 bool SequencedWorkerPool::PostNamedSequencedWorkerTask( | 1578 bool SequencedWorkerPool::PostNamedSequencedWorkerTask( |
| 1578 const std::string& token_name, | 1579 const std::string& token_name, |
| 1579 const tracked_objects::Location& from_here, | 1580 const tracked_objects::Location& from_here, |
| 1580 const Closure& task) { | 1581 Closure task) { |
| 1581 DCHECK(!token_name.empty()); | 1582 DCHECK(!token_name.empty()); |
| 1582 return inner_->PostTask(&token_name, SequenceToken(), BLOCK_SHUTDOWN, | 1583 return inner_->PostTask(&token_name, SequenceToken(), BLOCK_SHUTDOWN, |
| 1583 from_here, task, TimeDelta()); | 1584 from_here, std::move(task), TimeDelta()); |
| 1584 } | 1585 } |
| 1585 | 1586 |
| 1586 bool SequencedWorkerPool::PostSequencedWorkerTaskWithShutdownBehavior( | 1587 bool SequencedWorkerPool::PostSequencedWorkerTaskWithShutdownBehavior( |
| 1587 SequenceToken sequence_token, | 1588 SequenceToken sequence_token, |
| 1588 const tracked_objects::Location& from_here, | 1589 const tracked_objects::Location& from_here, |
| 1589 const Closure& task, | 1590 Closure task, |
| 1590 WorkerShutdown shutdown_behavior) { | 1591 WorkerShutdown shutdown_behavior) { |
| 1591 return inner_->PostTask(NULL, sequence_token, shutdown_behavior, | 1592 return inner_->PostTask(NULL, sequence_token, shutdown_behavior, from_here, |
| 1592 from_here, task, TimeDelta()); | 1593 std::move(task), TimeDelta()); |
| 1593 } | 1594 } |
| 1594 | 1595 |
| 1595 bool SequencedWorkerPool::PostDelayedTask( | 1596 bool SequencedWorkerPool::PostDelayedTask( |
| 1596 const tracked_objects::Location& from_here, | 1597 const tracked_objects::Location& from_here, |
| 1597 const Closure& task, | 1598 Closure task, |
| 1598 TimeDelta delay) { | 1599 TimeDelta delay) { |
| 1599 return PostDelayedWorkerTask(from_here, task, delay); | 1600 return PostDelayedWorkerTask(from_here, std::move(task), delay); |
| 1600 } | 1601 } |
| 1601 | 1602 |
| 1602 bool SequencedWorkerPool::RunsTasksOnCurrentThread() const { | 1603 bool SequencedWorkerPool::RunsTasksOnCurrentThread() const { |
| 1603 return inner_->RunsTasksOnCurrentThread(); | 1604 return inner_->RunsTasksOnCurrentThread(); |
| 1604 } | 1605 } |
| 1605 | 1606 |
| 1606 void SequencedWorkerPool::FlushForTesting() { | 1607 void SequencedWorkerPool::FlushForTesting() { |
| 1607 DCHECK(!RunsTasksOnCurrentThread()); | 1608 DCHECK(!RunsTasksOnCurrentThread()); |
| 1608 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 1609 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 1609 if (g_all_pools_state == AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) { | 1610 if (g_all_pools_state == AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1626 bool SequencedWorkerPool::IsShutdownInProgress() { | 1627 bool SequencedWorkerPool::IsShutdownInProgress() { |
| 1627 return inner_->IsShutdownInProgress(); | 1628 return inner_->IsShutdownInProgress(); |
| 1628 } | 1629 } |
| 1629 | 1630 |
| 1630 bool SequencedWorkerPool::IsRunningSequenceOnCurrentThread( | 1631 bool SequencedWorkerPool::IsRunningSequenceOnCurrentThread( |
| 1631 SequenceToken sequence_token) const { | 1632 SequenceToken sequence_token) const { |
| 1632 return inner_->IsRunningSequenceOnCurrentThread(sequence_token); | 1633 return inner_->IsRunningSequenceOnCurrentThread(sequence_token); |
| 1633 } | 1634 } |
| 1634 | 1635 |
| 1635 } // namespace base | 1636 } // namespace base |
| OLD | NEW |