1 #pragma once 2 3 #include <mbgl/util/logging.hpp> 4 #include <mbgl/util/async_task.hpp> 5 #include <mbgl/util/run_loop.hpp> 6 7 #include <QEventLoop> 8 #include <QObject> 9 #include <QSocketNotifier> 10 11 #include <unordered_map> 12 13 namespace mbgl { 14 namespace util { 15 16 using WatchCallback = std::function<void(int, RunLoop::Event)>; 17 using WatchPair = std::pair<std::unique_ptr<QSocketNotifier>, WatchCallback>; 18 19 class RunLoop::Impl : public QObject { 20 Q_OBJECT 21 22 public: 23 Impl() = default; 24 25 RunLoop::Type type; 26 27 std::unique_ptr<QEventLoop> loop; 28 std::unique_ptr<AsyncTask> async; 29 30 std::unordered_map<int, WatchPair> readPoll; 31 std::unordered_map<int, WatchPair> writePoll; 32 33 public slots: 34 void onReadEvent(int fd); 35 void onWriteEvent(int fd); 36 }; 37 38 } // namespace util 39 } // namespace mbgl 40