13 std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner) {
14 return std::shared_ptr<PipelineCompileQueue>(
19 std::shared_ptr<fml::ConcurrentTaskRunner> worker_task_runner)
20 : worker_task_runner_(
std::move(worker_task_runner)) {}
33 Lock lock(pending_jobs_mutex_);
34 auto insertion_result = pending_jobs_.insert(std::make_pair(desc, job));
35 if (!insertion_result.second) {
40 FML_LOG(ERROR) <<
"Got multiple compile jobs for the same descriptor. "
44 worker_task_runner_->PostTask(job);
49 worker_task_runner_->PostTask([weak_queue = weak_from_this()]() {
50 if (
auto queue = weak_queue.lock()) {
58 Lock lock(pending_jobs_mutex_);
59 if (pending_jobs_.empty()) {
62 auto job_iterator = pending_jobs_.begin();
63 auto job = job_iterator->second;
64 pending_jobs_.erase(job_iterator);
68fml::closure PipelineCompileQueue::TakeJob(
const PipelineDescriptor& desc) {
69 Lock lock(pending_jobs_mutex_);
70 auto found = pending_jobs_.find(desc);
71 if (found == pending_jobs_.end()) {
80 priorities_elevated_++;
82 reinterpret_cast<int64_t
>(
this),
83 "PrioritiesElevated", priorities_elevated_);
84 auto job = found->second;
85 pending_jobs_.erase(found);
89void PipelineCompileQueue::DoOneJob() {
90 if (
auto job = TakeNextJob()) {
95void PipelineCompileQueue::FinishAllJobs() {
99 bool has_jobs =
false;
101 Lock lock(pending_jobs_mutex_);
102 has_jobs = !pending_jobs_.empty();
113 if (
auto job = TakeJob(desc)) {
A task queue designed for managing compilation of pipeline state objects.
bool PostJobForDescriptor(const PipelineDescriptor &desc, const fml::closure &job)
Post a compile job for the specified descriptor.
static std::shared_ptr< PipelineCompileQueue > Create(std::shared_ptr< fml::ConcurrentTaskRunner > worker_task_runner)
PipelineCompileQueue(const PipelineCompileQueue &)=delete
virtual ~PipelineCompileQueue()
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...
#define FML_LOG(severity)
std::function< void()> closure
#define FML_TRACE_COUNTER(category_group, name, counter_id, arg1,...)