Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
30
libs/base/task_loop.hpp
Normal file
30
libs/base/task_loop.hpp
Normal file
|
|
@ -0,0 +1,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
|
||||
Loading…
Add table
Add a link
Reference in a new issue