summaryrefslogtreecommitdiff
path: root/src/mbgl/util/thread_context.hpp
blob: 2b22b2faf468e82e97bad8f5c6b2ddc0ec935411 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef MBGL_UTIL_THREAD_CONTEXT
#define MBGL_UTIL_THREAD_CONTEXT

#include <cstdint>
#include <string>
#include <thread>

namespace mbgl {

class FileSource;

namespace util {

class GLObjectStore;

enum class ThreadPriority : bool {
    Regular,
    Low,
};

enum class ThreadType : uint8_t {
    Main,
    Map,
    Worker,
    Unknown,
};

struct ThreadContext {
public:
    ThreadContext(const std::string& name, ThreadType type, ThreadPriority priority);

    static void Set(ThreadContext* context);

    static bool currentlyOn(ThreadType type);
    static std::string getName();
    static ThreadPriority getPriority();

    static FileSource* getFileSource();
    static void setFileSource(FileSource* fileSource);
    static GLObjectStore* getGLObjectStore();
    static void setGLObjectStore(GLObjectStore* glObjectStore);

    std::string name;
    ThreadType type;
    ThreadPriority priority;

    FileSource* fileSource = nullptr;
    GLObjectStore* glObjectStore = nullptr;
};

} // namespace util
} // namespace mbgl

#endif