• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_FML_PLATFORM_DARWIN_MESSAGE_LOOP_DARWIN_H_
6 #define FLUTTER_FML_PLATFORM_DARWIN_MESSAGE_LOOP_DARWIN_H_
7 
8 #include <CoreFoundation/CoreFoundation.h>
9 
10 #include <atomic>
11 
12 #include "flutter/fml/macros.h"
13 #include "flutter/fml/message_loop_impl.h"
14 #include "flutter/fml/platform/darwin/cf_utils.h"
15 
16 namespace fml {
17 
18 class MessageLoopDarwin : public MessageLoopImpl {
19  private:
20   std::atomic_bool running_;
21   CFRef<CFRunLoopTimerRef> delayed_wake_timer_;
22   CFRef<CFRunLoopRef> loop_;
23 
24   MessageLoopDarwin();
25 
26   ~MessageLoopDarwin() override;
27 
28   // |fml::MessageLoopImpl|
29   void Run() override;
30 
31   // |fml::MessageLoopImpl|
32   void Terminate() override;
33 
34   // |fml::MessageLoopImpl|
35   void WakeUp(fml::TimePoint time_point) override;
36 
37   static void OnTimerFire(CFRunLoopTimerRef timer, MessageLoopDarwin* loop);
38 
39   FML_FRIEND_MAKE_REF_COUNTED(MessageLoopDarwin);
40   FML_FRIEND_REF_COUNTED_THREAD_SAFE(MessageLoopDarwin);
41   FML_DISALLOW_COPY_AND_ASSIGN(MessageLoopDarwin);
42 };
43 
44 }  // namespace fml
45 
46 #endif  // FLUTTER_FML_PLATFORM_DARWIN_MESSAGE_LOOP_DARWIN_H_
47