5#include "flutter/fml/platform/android/message_loop_android.h"
10#include "flutter/fml/platform/linux/timerfd.h"
17 ALooper* looper = ALooper_forThread();
19 if (looper ==
nullptr) {
22 looper = ALooper_prepare(0);
27 ALooper_acquire(looper);
31MessageLoopAndroid::MessageLoopAndroid()
37 static const int kWakeEvents = ALOOPER_EVENT_INPUT;
39 ALooper_callbackFunc read_event_fd = [](
int,
int events,
void*
data) ->
int {
40 if (events & kWakeEvents) {
41 reinterpret_cast<MessageLoopAndroid*
>(
data)->OnEventFired();
46 int add_result = ::ALooper_addFd(looper_.get(),
48 ALOOPER_POLL_CALLBACK,
56MessageLoopAndroid::~MessageLoopAndroid() {
57 int remove_result = ::ALooper_removeFd(looper_.get(), timer_fd_.get());
62 FML_DCHECK(looper_.get() == ALooper_forThread());
67 int result = ::ALooper_pollOnce(-1,
72 if (
result == ALOOPER_POLL_TIMEOUT ||
result == ALOOPER_POLL_ERROR) {
79void MessageLoopAndroid::Terminate() {
81 ALooper_wake(looper_.get());
89void MessageLoopAndroid::OnEventFired() {
#define FML_CHECK(condition)
#define FML_DCHECK(condition)
static int64_t add_result
static constexpr int kClockType
bool TimerRearm(int fd, fml::TimePoint time_point)
Rearms the timer to expire at the given time point.
static ALooper * AcquireLooperForThread()
std::shared_ptr< const fml::Mapping > data
int timerfd_create(int clockid, int flags)