Files
MapLibreParticleLab/platform/android/src/run_loop_impl.hpp
Thiago Marcos P. Santos 10b503eabf [android] Attach thread on the RunLoop
Needed because Looper could be used by Java and it would crash
complaining that we didn't detach otherwise.
2016-04-06 04:52:51 -03:00

51 lines
859 B
C++

#pragma once
#include "jni.hpp"
#include <mbgl/util/chrono.hpp>
#include <mbgl/util/run_loop.hpp>
#include <atomic>
#include <list>
#include <memory>
#include <mutex>
struct ALooper;
namespace mbgl {
namespace util {
class RunLoop::Impl {
public:
class Runnable {
public:
virtual ~Runnable() = default;
virtual void runTask() = 0;
virtual TimePoint dueTime() const = 0;
std::list<Runnable*>::iterator iter;
};
void addRunnable(Runnable*);
void removeRunnable(Runnable*);
void initRunnable(Runnable*);
Milliseconds processRunnables();
private:
friend RunLoop;
JNIEnv *env = nullptr;
bool detach = false;
ALooper* loop = nullptr;
std::atomic<bool> running;
std::recursive_mutex mtx;
std::list<Runnable*> runnables;
};
} // namespace util
} // namespace mbgl