| Flutter Impeller |

Public Member Functions | Static Public Member Functions | List of all members
impeller::PipelineCompileQueue Class Referencefinal

A task queue designed for managing compilation of pipeline state objects. More...

`#include <pipeline_compile_queue.h>`

Inheritance diagram for impeller::PipelineCompileQueue:

## Public Member Functions
virtual | ~PipelineCompileQueue ()
| PipelineCompileQueue (const PipelineCompileQueue &)=delete
PipelineCompileQueue & | operator= (const PipelineCompileQueue &)=delete
bool | PostJobForDescriptor (const PipelineDescriptor &desc, const fml::closure &job)
| Post a compile job for the specified descriptor. More...
void | PerformJobEagerly (const PipelineDescriptor &desc)
| If the task has not yet been done, perform it eagerly on the calling thread. This can be used in lieu of an idle wait for the task completion on the calling thread. More...

## Static Public Member Functions
static std::shared_ptr< PipelineCompileQueue > | Create (std::shared_ptr< fml::ConcurrentTaskRunner > worker_task_runner)

## Detailed Description

A task queue designed for managing compilation of pipeline state objects.

The task queue attempts to perform compile jobs as quickly as possible by dispatching tasks to a concurrent task runner. These tasks are dispatched during renderer creation and usually complete before the first frame is rendered. In this ideal case, this queue is entirely unnecessary and and serves as a thin wrapper around just posting the compile jobs to a concurrent task runner.

If however, usually on lower end device, the compile jobs cannot be completed before the first frame is rendered, the implicit act of waiting for the compile job to be done can instead be augmented to take the pending job and perform it eagerly on the waiters thread. This effectively turns an idle wait into the job skipping to the front of the line and being done on the callers thread.

Again, the entire point of this class is the reduce startup times on the lowest end devices. On high end device, a queue is entirely optional. The queue skipping mechanism all assume the optional availability of a compile queue.

Definition at line 42 of file pipeline_compile_queue.h.

## Constructor & Destructor Documentation

## ◆ ~PipelineCompileQueue()

impeller::PipelineCompileQueue::~PipelineCompileQueue | ( |  | ) |
| virtual

Definition at line 22 of file pipeline_compile_queue.cc.

22 {
23 FinishAllJobs();
24 }

## ◆ PipelineCompileQueue()

impeller::PipelineCompileQueue::PipelineCompileQueue | ( | const PipelineCompileQueue & |  | ) |
| delete

Referenced by Create().

## Member Function Documentation

## ◆ Create()

std::shared_ptr< PipelineCompileQueue > impeller::PipelineCompileQueue::Create | ( | std::shared_ptr< fml::ConcurrentTaskRunner > | worker_task_runner | ) |
| static

Definition at line 12 of file pipeline_compile_queue.cc.

13 {
14 return std::shared_ptr<PipelineCompileQueue>(
15 new PipelineCompileQueue(std::move(worker_task_runner)));
16 }
impeller::PipelineCompileQueue::PipelineCompileQueue
PipelineCompileQueue(const PipelineCompileQueue &)=delete

References PipelineCompileQueue().

## ◆ operator=()

PipelineCompileQueue& impeller::PipelineCompileQueue::operator= | ( | const PipelineCompileQueue & |  | ) |
| delete

## ◆ PerformJobEagerly()

void impeller::PipelineCompileQueue::PerformJobEagerly | ( | const PipelineDescriptor & | desc | ) |

If the task has not yet been done, perform it eagerly on the calling thread. This can be used in lieu of an idle wait for the task completion on the calling thread.

Parameters

  [in] | desc | The description

Definition at line 112 of file pipeline_compile_queue.cc.

112 {
113 if (auto job = TakeJob(desc)) {
114 job();
115 }
116 }

Referenced by impeller::GenericRenderPipelineHandle::WaitAndGet().

## ◆ PostJobForDescriptor()

bool impeller::PipelineCompileQueue::PostJobForDescriptor | ( | const PipelineDescriptor & | desc,
|  | const fml::closure & | job
| ) |  |

Post a compile job for the specified descriptor.

Parameters

  [in] | desc | The description
  [in] | job | The job

Returns
  If the job was successfully posted to the parallel task runners.

Definition at line 26 of file pipeline_compile_queue.cc.

27 {
28 if (!job) {
29 return false;
30 }
31
32 {
33 Lock lock(pending_jobs_mutex_);
34 auto insertion_result = pending_jobs_.insert(std::make_pair(desc, job));
35 if (!insertion_result.second) {
36 // This bit is being extremely conservative. If insertion did not take
37 // place, someone gave the compile queue a job for the same description.
38 // This is highly unusual but technically not impossible. Just run the job
39 // eagerly.
40 FML_LOG(ERROR) << "Got multiple compile jobs for the same descriptor. "
41 "Running eagerly.";
42 // Don't invoke the job here has there are we have currently acquired a
43 // mutex.
44 worker_task_runner_->PostTask(job);
45 return true;
46 }
47 }
48
49 worker_task_runner_->PostTask([weak_queue = weak_from_this()]() {
50 if (auto queue = weak_queue.lock()) {
51 queue->DoOneJob();
52 }
53 });
54 return true;
55 }

The documentation for this class was generated from the following files:

- impeller/renderer/pipeline_compile_queue.h
- impeller/renderer/pipeline_compile_queue.cc