blob: 27a5eda5a528dd3481f367fb85177a41a638c0a7 [file] [log] [blame]
Danil Chapovalov959e9b62019-01-14 14:29:18 +01001/*
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
13namespace webrtc {
14
15// Base interface for asynchronously executed tasks.
16// The interface basically consists of a single function, Run(), that executes
17// on the target queue. For more details see the Run() method and TaskQueue.
18class QueuedTask {
19 public:
20 virtual ~QueuedTask() = default;
21
22 // Main routine that will run when the task is executed on the desired queue.
Artem Titov0e61fdd2021-07-25 21:50:14 +020023 // The task should return `true` to indicate that it should be deleted or
24 // `false` to indicate that the queue should consider ownership of the task
25 // having been transferred. Returning `false` can be useful if a task has
Danil Chapovalov959e9b62019-01-14 14:29:18 +010026 // re-posted itself to a different queue or is otherwise being re-used.
27 virtual bool Run() = 0;
28};
29
30} // namespace webrtc
31
32#endif // API_TASK_QUEUE_QUEUED_TASK_H_