Flutter Engine
task_observers.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_SHELL_PLATFORM_FUCHSIA_TASK_OBSERVERS_H_
6 #define FLUTTER_SHELL_PLATFORM_FUCHSIA_TASK_OBSERVERS_H_
7 
8 #include <lib/fit/function.h>
9 
10 namespace fml {
11 
12 // Executes all closures that were registered via
13 // `CurrentMessageLoopAddAfterTaskObserver` on this thread.
14 //
15 // WARNING(fxbug.dev/77957): These task observers are distinct from the task
16 // observers that can be specified via `fml::MessageLoop::AddTaskObserver` and
17 // they behave differently!
18 //
19 // Task observers registered via `fml::MessageLoop::AddTaskObserver` only fire
20 // after work that was posted via the `fml::MessageLoop`'s `TaskRunner`
21 // completes. Work that is posted directly to the Fuchsia message loop (e.g.
22 // using `async::PostTask(async_get_default_dispatcher(), ...)`) is invisible to
23 // `fml::MessageLoop`, so the `fml::MessageLoop`'s task observers don't fire.
24 //
25 // The task observers registered with `CurrentMessageLoopAddAfterTaskObserver`,
26 // however, fire after _every_ work item is completed, regardless of whether it
27 // was posted to the Fuchsia message loop directly or via `fml::MessageLoop`.
28 //
29 // These two mechanisms are redundant and confusing, so we should fix it
30 // somehow.
32 
34  fit::closure observer);
35 
37 
38 } // namespace fml
39 
40 #endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_TASK_OBSERVERS_H_
void ExecuteAfterTaskObservers()
Definition: ascii_trie.cc:9
std::function< void()> closure
Definition: closure.h:14
void CurrentMessageLoopRemoveAfterTaskObserver(intptr_t key)
void CurrentMessageLoopAddAfterTaskObserver(intptr_t key, fit::closure observer)