| Flutter Linux Embedder |

fl_task_runner.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_LINUX_FL_TASK_RUNNER_H_
6 #define FLUTTER_SHELL_PLATFORM_LINUX_FL_TASK_RUNNER_H_
7
8 #include <glib-object.h>
9
10 #include "flutter/shell/platform/embedder/embedder.h"
11 #include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"
12
13 G_BEGIN_DECLS
14
15 G_DECLARE_FINAL_TYPE(FlTaskRunner, fl_task_runner, FL, TASK_RUNNER, GObject);
16
17 /**
18 * fl_task_runner_new:
19 * @engine: the #FlEngine owning the task runner.
20 *
21 * Creates new task runner instance.
22 *
23 * Returns: an #FlTaskRunner.
24 */
25 FlTaskRunner* fl_task_runner_new(FlEngine* engine);
26
27 /**
28 * fl_task_runner_post_flutter_task:
29 * @task_runner: an #FlTaskRunner.
30 * @task: Flutter task being scheduled
31 * @target_time_nanos: absolute time in nanoseconds
32 *
33 * Posts a Flutter task to be executed on main thread. This function is thread
34 * safe and may be called from any thread.
35 */
36 void fl_task_runner_post_flutter_task(FlTaskRunner* task_runner,
37 FlutterTask task,
38 uint64_t target_time_nanos);
39
40 /**
41 * fl_task_runner_post_callback:
42 * @task_runner: an #FlTaskRunner.
43 * @callback: callback to be scheduled
44 * @data: data to be passed to the callback
45 *
46 * Schedules arbitrary callback to be executed on main thread. The callback
47 * will be executed in next run loop turn. This function is thread
48 * safe and may be called from any thread.
49 */
50 void fl_task_runner_post_callback(FlTaskRunner* task_runner,
51 void (*callback)(gpointer data),
52 gpointer data);
53
54 /**
55 * fl_task_runner_block_main_thread:
56 * @task_runner: an #FlTaskRunner.
57 *
58 * Blocks main thread until fl_task_runner_release_main_thread is called.
59 * While main thread is blocked tasks posted to #FlTaskRunner are executed as
60 * usual.
61 * Must be invoked on main thread.
62 */
63 void fl_task_runner_block_main_thread(FlTaskRunner* task_runner);
64
65 /**
66 * fl_task_runner_release_main_thread:
67 * @task_runner: an #FlTaskRunner.
68 *
69 * Unblocks main thread. This will resume normal processing of main loop.
70 * Can be invoked from any thread.
71 */
72 void fl_task_runner_release_main_thread(FlTaskRunner* self);
73
74 G_END_DECLS
75
76 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_TASK_RUNNER_H_
FL
FL
Definition: fl_binary_messenger.cc:27
fl_engine.h
G_DECLARE_FINAL_TYPE
G_BEGIN_DECLS G_DECLARE_FINAL_TYPE(FlTaskRunner, fl_task_runner, FL, TASK_RUNNER, GObject)
fl_task_runner_post_flutter_task
void fl_task_runner_post_flutter_task(FlTaskRunner *task_runner, FlutterTask task, uint64_t target_time_nanos)
Definition: fl_task_runner.cc:174
fl_task_runner_post_callback
void fl_task_runner_post_callback(FlTaskRunner *task_runner, void(*callback)(gpointer data), gpointer data)
Definition: fl_task_runner.cc:189
fl_task_runner_release_main_thread
void fl_task_runner_release_main_thread(FlTaskRunner *self)
Definition: fl_task_runner.cc:224
fl_task_runner_block_main_thread
void fl_task_runner_block_main_thread(FlTaskRunner *task_runner)
Definition: fl_task_runner.cc:203
fl_task_runner_new
FlTaskRunner * fl_task_runner_new(FlEngine *engine)
Definition: fl_task_runner.cc:167