blob: 2fcdd41b65279f9d62b2f0f8a1a98bfd10f30e22 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#pragma once
#include <cstdint>
#include <functional>
namespace base
{
class TaskLoop
{
public:
using Task = std::function<void()>;
using TaskId = uint64_t;
static TaskId constexpr kNoId = 0;
struct PushResult
{
// Contains true when task is posted successfully.
bool m_isSuccess = false;
// Contains id of posted task which can be used to access the task to cancel/suspend/etc it.
// kNoId is returned for tasks that cannot be accessed.
TaskId m_id = kNoId;
};
virtual ~TaskLoop() = default;
virtual PushResult Push(Task && task) = 0;
virtual PushResult Push(Task const & task) = 0;
};
} // namespace base
|