1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_TASK_THREAD_POOL_POOLED_SEQUENCED_TASK_RUNNER_H_ 6 #define BASE_TASK_THREAD_POOL_POOLED_SEQUENCED_TASK_RUNNER_H_ 7 8 #include "base/base_export.h" 9 #include "base/callback_forward.h" 10 #include "base/location.h" 11 #include "base/task/task_traits.h" 12 #include "base/task/thread_pool/pooled_task_runner_delegate.h" 13 #include "base/task/thread_pool/sequence.h" 14 #include "base/time/time.h" 15 #include "base/updateable_sequenced_task_runner.h" 16 17 namespace base { 18 namespace internal { 19 20 // A task runner that runs tasks in sequence. 21 class BASE_EXPORT PooledSequencedTaskRunner 22 : public UpdateableSequencedTaskRunner { 23 public: 24 // Constructs a PooledSequencedTaskRunner which can be used to post tasks. 25 PooledSequencedTaskRunner( 26 const TaskTraits& traits, 27 PooledTaskRunnerDelegate* pooled_task_runner_delegate); 28 PooledSequencedTaskRunner(const PooledSequencedTaskRunner&) = delete; 29 PooledSequencedTaskRunner& operator=(const PooledSequencedTaskRunner&) = 30 delete; 31 32 // UpdateableSequencedTaskRunner: 33 bool PostDelayedTask(const Location& from_here, 34 OnceClosure closure, 35 TimeDelta delay) override; 36 37 bool PostNonNestableDelayedTask(const Location& from_here, 38 OnceClosure closure, 39 TimeDelta delay) override; 40 41 bool RunsTasksInCurrentSequence() const override; 42 43 void UpdatePriority(TaskPriority priority) override; 44 45 private: 46 ~PooledSequencedTaskRunner() override; 47 48 PooledTaskRunnerDelegate* const pooled_task_runner_delegate_; 49 50 // Sequence for all Tasks posted through this TaskRunner. 51 const scoped_refptr<Sequence> sequence_; 52 }; 53 54 } // namespace internal 55 } // namespace base 56 57 #endif // BASE_TASK_THREAD_POOL_POOLED_SEQUENCED_TASK_RUNNER_H_ 58