blob: a3efa92a836f728a343b23ba3065f211d34cce17 (
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
55
56
57
58
59
60
61
62
63
64
|
#pragma once
#include "jni.hpp"
#include <mbgl/util/chrono.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/util/thread.hpp>
#include <atomic>
#include <list>
#include <memory>
#include <mutex>
struct ALooper;
namespace mbgl {
namespace util {
class Alarm;
class RunLoop::Impl {
public:
class Runnable {
public:
virtual ~Runnable() = default;
virtual void runTask() = 0;
virtual TimePoint dueTime() const = 0;
std::list<Runnable*>::iterator iter;
};
Impl(RunLoop*, RunLoop::Type);
~Impl();
void wake();
void addRunnable(Runnable*);
void removeRunnable(Runnable*);
void initRunnable(Runnable*);
Milliseconds processRunnables();
ALooper* loop = nullptr;
RunLoop* runLoop = nullptr;
std::atomic<bool> running;
private:
friend RunLoop;
int fds[2];
JNIEnv *env = nullptr;
bool detach = false;
std::unique_ptr<Thread<Alarm>> alarm;
std::recursive_mutex mtx;
std::list<Runnable*> runnables;
std::list<Runnable*>::iterator nextRunnable;
};
} // namespace util
} // namespace mbgl
|