queued_task.h 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright 2018 The WebRTC Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef API_TASK_QUEUE_QUEUED_TASK_H_
  11. #define API_TASK_QUEUE_QUEUED_TASK_H_
  12. namespace webrtc {
  13. // Base interface for asynchronously executed tasks.
  14. // The interface basically consists of a single function, Run(), that executes
  15. // on the target queue. For more details see the Run() method and TaskQueue.
  16. class QueuedTask {
  17. public:
  18. virtual ~QueuedTask() = default;
  19. // Main routine that will run when the task is executed on the desired queue.
  20. // The task should return |true| to indicate that it should be deleted or
  21. // |false| to indicate that the queue should consider ownership of the task
  22. // having been transferred. Returning |false| can be useful if a task has
  23. // re-posted itself to a different queue or is otherwise being re-used.
  24. virtual bool Run() = 0;
  25. };
  26. } // namespace webrtc
  27. #endif // API_TASK_QUEUE_QUEUED_TASK_H_