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_SEQUENCE_MANAGER_SEQUENCED_TASK_SOURCE_H_ 6 #define BASE_TASK_SEQUENCE_MANAGER_SEQUENCED_TASK_SOURCE_H_ 7 8 #include "base/optional.h" 9 #include "base/pending_task.h" 10 #include "base/task/sequence_manager/lazy_now.h" 11 12 namespace base { 13 namespace sequence_manager { 14 namespace internal { 15 16 // Interface to pass tasks to ThreadController. 17 class SequencedTaskSource { 18 public: 19 // Returns the next task to run from this source or nullopt if 20 // there're no more tasks ready to run. If a task is returned, 21 // DidRunTask() must be invoked before the next call to TakeTask(). 22 virtual Optional<PendingTask> TakeTask() = 0; 23 24 // Notifies this source that the task previously obtained 25 // from TakeTask() has been completed. 26 virtual void DidRunTask() = 0; 27 28 // Returns the delay till the next task or TimeDelta::Max() 29 // if there are no tasks left. 30 virtual TimeDelta DelayTillNextTask(LazyNow* lazy_now) = 0; 31 }; 32 33 } // namespace internal 34 } // namespace sequence_manager 35 } // namespace base 36 37 #endif // BASE_TASK_SEQUENCE_MANAGER_SEQUENCED_TASK_SOURCE_H_ 38