7#include <CoreFoundation/CFRunLoop.h>
8#include <Foundation/Foundation.h>
18MessageLoopDarwin::MessageLoopDarwin()
19 : running_(false), loop_((CFRunLoopRef)CFRetain(CFRunLoopGetCurrent())) {
23 CFRunLoopTimerContext timer_context = {
26 delayed_wake_timer_.Reset(
29 reinterpret_cast<CFRunLoopTimerCallBack
>(&MessageLoopDarwin::OnTimerFire)
33 CFRunLoopAddTimer(loop_, delayed_wake_timer_, kCFRunLoopCommonModes);
35 CFRunLoopAddTimer(loop_, delayed_wake_timer_, kMessageLoopCFRunLoopMode);
38MessageLoopDarwin::~MessageLoopDarwin() {
39 CFRunLoopTimerInvalidate(delayed_wake_timer_);
40 CFRunLoopRemoveTimer(loop_, delayed_wake_timer_, kCFRunLoopCommonModes);
41 CFRunLoopRemoveTimer(loop_, delayed_wake_timer_, kMessageLoopCFRunLoopMode);
44void MessageLoopDarwin::Run() {
51 int result = CFRunLoopRunInMode(kCFRunLoopDefaultMode,
kDistantFuture, YES);
52 if (result == kCFRunLoopRunStopped || result == kCFRunLoopRunFinished) {
64void MessageLoopDarwin::Terminate() {
69 CFRef<CFRunLoopRef> local_loop(loop_);
71 CFRunLoopStop(local_loop);
77 CFRunLoopTimerSetNextFireDate(
82void MessageLoopDarwin::OnTimerFire(CFRunLoopTimerRef timer, MessageLoopDarwin* loop) {
85 loop->RunExpiredTasksNow();
static CFStringRef kMessageLoopCFRunLoopMode
#define FML_DCHECK(condition)
static FLUTTER_ASSERT_ARC constexpr CFTimeInterval kDistantFuture
static constexpr CFTimeInterval kDistantFuture