2020-10-04 16:06:34 +02:00
|
|
|
#ifndef RUNNER_RUN_LOOP_H_
|
|
|
|
#define RUNNER_RUN_LOOP_H_
|
2020-09-27 11:18:38 +02:00
|
|
|
|
2020-10-04 16:06:34 +02:00
|
|
|
#include <flutter/flutter_engine.h>
|
2020-09-27 11:18:38 +02:00
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
// A runloop that will service events for Flutter instances as well
|
|
|
|
// as native messages.
|
|
|
|
class RunLoop {
|
|
|
|
public:
|
|
|
|
RunLoop();
|
|
|
|
~RunLoop();
|
|
|
|
|
|
|
|
// Prevent copying
|
|
|
|
RunLoop(RunLoop const&) = delete;
|
|
|
|
RunLoop& operator=(RunLoop const&) = delete;
|
|
|
|
|
|
|
|
// Runs the run loop until the application quits.
|
|
|
|
void Run();
|
|
|
|
|
|
|
|
// Registers the given Flutter instance for event servicing.
|
|
|
|
void RegisterFlutterInstance(
|
2020-10-04 16:06:34 +02:00
|
|
|
flutter::FlutterEngine* flutter_instance);
|
2020-09-27 11:18:38 +02:00
|
|
|
|
|
|
|
// Unregisters the given Flutter instance from event servicing.
|
|
|
|
void UnregisterFlutterInstance(
|
2020-10-04 16:06:34 +02:00
|
|
|
flutter::FlutterEngine* flutter_instance);
|
2020-09-27 11:18:38 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
using TimePoint = std::chrono::steady_clock::time_point;
|
|
|
|
|
|
|
|
// Processes all currently pending messages for registered Flutter instances.
|
|
|
|
TimePoint ProcessFlutterMessages();
|
|
|
|
|
2020-10-04 16:06:34 +02:00
|
|
|
std::set<flutter::FlutterEngine*> flutter_instances_;
|
2020-09-27 11:18:38 +02:00
|
|
|
};
|
|
|
|
|
2020-10-04 16:06:34 +02:00
|
|
|
#endif // RUNNER_RUN_LOOP_H_
|