Grindstone Game Engine
v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
TaskSystem.hpp
1
#pragma once
2
3
#include <map>
4
#include <mutex>
5
#include <thread>
6
#include <functional>
7
#include <string>
8
9
#include <Common/ResourcePipeline/Uuid.hpp>
10
11
namespace
Grindstone::Editor {
12
struct
Task
{
13
enum class
Status {
14
Queued,
15
InProgress,
16
Done
17
};
18
19
std::string name;
20
std::function<void()> fnPtr;
21
std::thread thread;
22
Status status;
23
24
Task
() =
default
;
25
Task
(
const
Task
& other);
26
Task
(
Task
&& other) =
default
;
27
Task
(std::string& name, std::function<
void
()> fnPtr) : name(name), fnPtr(fnPtr), status(Status::Queued) {}
28
};
29
30
class
TaskSystem
{
31
public
:
32
TaskSystem
();
33
~TaskSystem
();
34
std::vector<Task> GetTasks();
35
void
Execute(std::string jobName, std::function<
void
()> jobPtr);
36
void
CullDoneTasks();
37
bool
HasRunningTasks();
38
private
:
39
std::map<Uuid, Task> tasks;
40
std::mutex mutex;
41
};
42
}
Grindstone::Editor::TaskSystem
Definition
TaskSystem.hpp:30
Grindstone::Editor::Task
Definition
TaskSystem.hpp:12
sources
code
Editor
TaskSystem.hpp
Generated by
1.12.0