task.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2016 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. #ifndef BASE_TASK_THREAD_POOL_TASK_H_
  5. #define BASE_TASK_THREAD_POOL_TASK_H_
  6. #include "base/base_export.h"
  7. #include "base/callback.h"
  8. #include "base/location.h"
  9. #include "base/macros.h"
  10. #include "base/memory/ref_counted.h"
  11. #include "base/pending_task.h"
  12. #include "base/sequenced_task_runner.h"
  13. #include "base/single_thread_task_runner.h"
  14. #include "base/time/time.h"
  15. namespace base {
  16. namespace internal {
  17. // A task is a unit of work inside the thread pool. Support for tracing and
  18. // profiling inherited from PendingTask.
  19. // TODO(etiennep): This class is now equivalent to PendingTask, remove it.
  20. struct BASE_EXPORT Task : public PendingTask {
  21. Task();
  22. // |posted_from| is the site the task was posted from. |task| is the closure
  23. // to run. |delay| is a delay that must expire before the Task runs.
  24. Task(const Location& posted_from, OnceClosure task, TimeDelta delay);
  25. // Task is move-only to avoid mistakes that cause reference counts to be
  26. // accidentally bumped.
  27. Task(Task&& other) noexcept;
  28. ~Task();
  29. Task& operator=(Task&& other);
  30. private:
  31. DISALLOW_COPY_AND_ASSIGN(Task);
  32. };
  33. } // namespace internal
  34. } // namespace base
  35. #endif // BASE_TASK_THREAD_POOL_TASK_H_