Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
11namespace fml {
12
13class TaskRunner;
14class MessageLoopImpl;
15
16/// An event loop associated with a thread.
17///
18/// This class is the generic front-end to the MessageLoop, differences in
19/// implementation based on the running platform are in the subclasses of
20/// flutter::MessageLoopImpl (ex flutter::MessageLoopAndroid).
21///
22/// For scheduling events on the message loop see flutter::TaskRunner.
23///
24/// \see fml::TaskRunner
25/// \see fml::MessageLoopImpl
26/// \see fml::MessageLoopTaskQueues
27/// \see fml::Wakeable
29 public:
31 static MessageLoop& GetCurrent();
32
33 void Run();
34
35 void Terminate();
36
37 void AddTaskObserver(intptr_t key, const fml::closure& callback);
38
39 void RemoveTaskObserver(intptr_t key);
40
42
43 // Exposed for the embedder shell which allows clients to poll for events
44 // instead of dedicating a thread to the message loop.
45 void RunExpiredTasksNow();
46
48
49 /// Returns true if \p EnsureInitializedForCurrentThread has been called on
50 /// this thread already.
52
54
55 /// Gets the unique identifier for the TaskQueue associated with the current
56 /// thread.
57 /// \see fml::MessageLoopTaskQueues
59
60 private:
61 friend class TaskRunner;
62 friend class MessageLoopImpl;
63
66
68
69 fml::RefPtr<MessageLoopImpl> GetLoopImpl() const;
70
72};
73
74} // namespace fml
75
76#endif // FLUTTER_FML_MESSAGE_LOOP_H_
void RemoveTaskObserver(intptr_t key)
static void EnsureInitializedForCurrentThread()
void AddTaskObserver(intptr_t key, const fml::closure &callback)
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
static bool IsInitializedForCurrentThread()
static TaskQueueId GetCurrentTaskQueueId()
void RunExpiredTasksNow()
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_EMBEDDER_ONLY
Definition macros.h:10
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
std::function< void()> closure
Definition closure.h:14