#pragma once #include "jni.hpp" #include #include #include #include #include #include struct ALooper; namespace mbgl { namespace util { template class Thread; class Alarm; class RunLoop::Impl { public: class Runnable { public: virtual ~Runnable() = default; virtual void runTask() = 0; virtual TimePoint dueTime() const = 0; }; Impl(RunLoop*, RunLoop::Type); ~Impl(); void wake(); void addRunnable(Runnable*); void removeRunnable(Runnable*); Milliseconds processRunnables(); ALooper* loop = nullptr; RunLoop* runLoop = nullptr; std::atomic running; std::atomic_flag coalesce = ATOMIC_FLAG_INIT; private: friend RunLoop; int fds[2]; std::unique_ptr> alarm; std::mutex mutex; std::list runnables; }; } // namespace util } // namespace mbgl