Flutter Engine
message_loop.h
Go to the documentation of this file.
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_MESSAGE_LOOP_H_
6 #define FLUTTER_FML_MESSAGE_LOOP_H_
7 
8 #include "flutter/fml/macros.h"
9 #include "flutter/fml/task_runner.h"
10 
11 namespace fml {
12 
13 class TaskRunner;
14 class MessageLoopImpl;
15 
16 class MessageLoop {
17  public:
19  static MessageLoop& GetCurrent();
20 
21  bool IsValid() const;
22 
23  void Run();
24 
25  void Terminate();
26 
27  void AddTaskObserver(intptr_t key, const fml::closure& callback);
28 
29  void RemoveTaskObserver(intptr_t key);
30 
32 
33  // Exposed for the embedder shell which allows clients to poll for events
34  // instead of dedicating a thread to the message loop.
35  void RunExpiredTasksNow();
36 
38 
39  static bool IsInitializedForCurrentThread();
40 
41  ~MessageLoop();
42 
44 
45  private:
46  friend class TaskRunner;
47  friend class MessageLoopImpl;
48 
50  fml::RefPtr<fml::TaskRunner> task_runner_;
51 
52  MessageLoop();
53 
54  fml::RefPtr<MessageLoopImpl> GetLoopImpl() const;
55 
57 };
58 
59 } // namespace fml
60 
61 #endif // FLUTTER_FML_MESSAGE_LOOP_H_
void AddTaskObserver(intptr_t key, const fml::closure &callback)
Definition: message_loop.cc:64
bool IsValid() const
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
Definition: message_loop.cc:19
static void EnsureInitializedForCurrentThread()
Definition: message_loop.cc:27
Definition: ascii_trie.cc:9
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
Definition: message_loop.cc:56
static TaskQueueId GetCurrentTaskQueueId()
Definition: message_loop.cc:76
std::function< void()> closure
Definition: closure.h:14
void RunExpiredTasksNow()
Definition: message_loop.cc:72
void RemoveTaskObserver(intptr_t key)
Definition: message_loop.cc:68
static bool IsInitializedForCurrentThread()
Definition: message_loop.cc:35
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:27
#define FML_EMBEDDER_ONLY
Definition: macros.h:10