| Flutter Linux Embedder |

Functions
fl_task_runner.h File Reference
`#include <glib-object.h>`
`#include "flutter/shell/platform/embedder/embedder.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"`

Go to the source code of this file.

## Functions
G_BEGIN_DECLS | G_DECLARE_FINAL_TYPE (FlTaskRunner, fl_task_runner, FL, TASK_RUNNER, GObject)
FlTaskRunner * | fl_task_runner_new (FlEngine *engine)
void | fl_task_runner_post_flutter_task (FlTaskRunner *task_runner, FlutterTask task, uint64_t target_time_nanos)
void | fl_task_runner_wait (FlTaskRunner *task_runner)
void | fl_task_runner_stop_wait (FlTaskRunner *self)

## Function Documentation

## ◆ fl_task_runner_new()

FlTaskRunner* fl_task_runner_new | ( | FlEngine * | engine | ) |

fl_task_runner_new: @engine: the #FlEngine owning the task runner.

Creates new task runner instance.

Returns: an #FlTaskRunner.

Definition at line 147 of file fl_task_runner.cc.

147 {
148 FlTaskRunner* self =
149 FL_TASK_RUNNER(g_object_new(fl_task_runner_get_type(), nullptr));
150 g_weak_ref_init(&self->engine, G_OBJECT(engine));
151 return self;
152 }

Referenced by fl_engine_init(), and TEST().

## ◆ fl_task_runner_post_flutter_task()

void fl_task_runner_post_flutter_task | ( | FlTaskRunner * | task_runner,
|  | FlutterTask | task,
|  | uint64_t | target_time_nanos
| ) |  |

fl_task_runner_post_flutter_task: @task_runner: an #FlTaskRunner. @task: Flutter task being scheduled @target_time_nanos: absolute time in nanoseconds

Posts a Flutter task to be executed on main thread. This function is thread safe and may be called from any thread.

Definition at line 154 of file fl_task_runner.cc.

156 {
157 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&self->mutex);
158 (void)locker; // unused variable
159
160 FlTaskRunnerTask* runner_task = g_new0(FlTaskRunnerTask, 1);
161 runner_task->task = task;
162 runner_task->task_time_micros =
163 target_time_nanos / kMicrosecondsPerNanosecond;
164
165 self->pending_tasks = g_list_append(self->pending_tasks, runner_task);
166 fl_task_runner_tasks_did_change_locked(self);
167
168 // Tasks changed, so wake up anything blocking in fl_task_runner_wait.
169 g_cond_signal(&self->cond);
170 }
g_autoptr
g_autoptr(GMutexLocker) locker
fl_task_runner_tasks_did_change_locked
static void fl_task_runner_tasks_did_change_locked(FlTaskRunner *self)
Definition: fl_task_runner.cc:108
kMicrosecondsPerNanosecond
static constexpr int kMicrosecondsPerNanosecond
Definition: fl_task_runner.cc:8
_FlTaskRunnerTask
Definition: fl_task_runner.cc:23
_FlTaskRunnerTask::task
FlutterTask task
Definition: fl_task_runner.cc:29
_FlTaskRunnerTask::task_time_micros
gint64 task_time_micros
Definition: fl_task_runner.cc:25

References fl_task_runner_tasks_did_change_locked(), g_autoptr(), kMicrosecondsPerNanosecond, _FlTaskRunnerTask::task, and _FlTaskRunnerTask::task_time_micros.

Referenced by fl_engine_post_task().

## ◆ fl_task_runner_stop_wait()

void fl_task_runner_stop_wait | ( | FlTaskRunner * | self | ) |

fl_task_runner_stop_wait: @task_runner: an #FlTaskRunner.

Cause fl_task_runner_wait() to complete. May be called even if fl_task_runner_wait() is not being used.

May be called by any thread.

Definition at line 182 of file fl_task_runner.cc.

182 {
183 g_cond_signal(&self->cond);
184 }

## ◆ fl_task_runner_wait()

void fl_task_runner_wait | ( | FlTaskRunner * | task_runner | ) |

fl_task_runner_wait: @task_runner: an #FlTaskRunner.

Block until the next task is ready and then perform it. May be interrupted by fl_task_runner_stop_wait(), in which case no task is run but execution will be returned to the caller.

Must be called only by the GTK thread.

Definition at line 172 of file fl_task_runner.cc.

172 {
173 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&self->mutex);
174 (void)locker; // unused variable
175
176 g_cond_wait_until(&self->cond, &self->mutex,
177 fl_task_runner_next_task_expiration_time_locked(self));
178 fl_task_runner_process_expired_tasks_locked(self);
179 fl_task_runner_tasks_did_change_locked(self);
180 }
fl_task_runner_process_expired_tasks_locked
static void fl_task_runner_process_expired_tasks_locked(FlTaskRunner *self)
Definition: fl_task_runner.cc:36
fl_task_runner_next_task_expiration_time_locked
static gint64 fl_task_runner_next_task_expiration_time_locked(FlTaskRunner *self)
Definition: fl_task_runner.cc:96

References fl_task_runner_next_task_expiration_time_locked(), fl_task_runner_process_expired_tasks_locked(), fl_task_runner_tasks_did_change_locked(), and g_autoptr().

Referenced by fl_compositor_opengl_render(), and fl_compositor_software_render().

## ◆ G_DECLARE_FINAL_TYPE()

G_BEGIN_DECLS G_DECLARE_FINAL_TYPE | ( | FlTaskRunner | ,
|  | fl_task_runner | ,
|  | FL | ,
|  | TASK_RUNNER | ,
|  | GObject |
| ) |  |