Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
pipeline_compile_queue_gles.cc
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
6
10
11namespace impeller {
12
13std::shared_ptr<PipelineCompileQueueGLES> PipelineCompileQueueGLES::Create(
14 std::shared_ptr<fml::BasicTaskRunner> worker_task_runner) {
15 if (!worker_task_runner) {
16 return nullptr;
17 }
18 return std::shared_ptr<PipelineCompileQueueGLES>(
19 new PipelineCompileQueueGLES(std::move(worker_task_runner)));
20}
21
23 std::shared_ptr<fml::BasicTaskRunner> worker_task_runner)
24 : worker_task_runner_(std::move(worker_task_runner)) {}
25
27
29 // To prevent potential deadlocks and reduce lock contention, avoid calling
30 // external or virtual methods (such as DrainPendingJobs, which posts tasks
31 // to the task runner) while holding a mutex. Instead, minimize the scope of
32 // the lock by using a local boolean flag to trigger the draining process
33 // outside the lock block.
34 bool should_drain = false;
35 {
36 Lock lock(processing_mutex_);
37 if (!is_processing_) {
38 is_processing_ = true;
39 should_drain = true;
40 }
41 }
42 if (should_drain) {
43 DrainPendingJobs();
44 }
45}
46
48 if (!job) {
49 return;
50 }
51
52 worker_task_runner_->PostTask(job);
53}
54
55void PipelineCompileQueueGLES::DrainPendingJobs() {
56 PostJob([weak_queue = weak_from_this()]() {
57 if (auto queue = std::static_pointer_cast<PipelineCompileQueueGLES>(
58 weak_queue.lock())) {
59 queue->DoOneJob();
60 {
61 Lock lock(queue->processing_mutex_);
62 if (!queue->HasPendingJobs()) {
63 queue->is_processing_ = false;
64 return;
65 }
66 }
67 queue->DrainPendingJobs();
68 }
69 });
70}
71
72} // namespace impeller
A task queue designed for managing compilation of pipeline state objects for OpenGL ES backend.
void PostJob(const fml::closure &job) override
Post a compilation job to the worker task runner.
PipelineCompileQueueGLES(const PipelineCompileQueueGLES &)=delete
void OnJobAdded() override
Called by PostJobForDescriptor after a job has been successfully added to the queue....
static std::shared_ptr< PipelineCompileQueueGLES > Create(std::shared_ptr< fml::BasicTaskRunner > worker_task_runner)
VkQueue queue
Definition main.cc:71
std::function< void()> closure
Definition closure.h:14
Definition ref_ptr.h:261