MCPcopy Create free account
hub / github.com/defold/defold / SelectAndPopJob

Function SelectAndPopJob

engine/dlib/src/dlib/jobsystem.cpp:488–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486}
487
488static HJob SelectAndPopJob(JobThreadContext* ctx, uint64_t time, JobItem** out_item)
489{
490 uint32_t size = ctx->m_Work.Size();
491 for (uint32_t i = 0; i < size;)
492 {
493 HJob hjob = ctx->m_Work[i];
494 JobItem* item = GetJobItem(ctx, hjob);
495
496 bool children_finished = item->m_NumChildren == item->m_NumChildrenCompleted;
497
498 // Check if the item meets our criteria
499 if (item->m_Status == JOBSYSTEM_STATUS_CANCELED && children_finished)
500 {
501 size--;
502 ctx->m_Work.Erase(i);
503 PutDone(ctx, hjob, JOBSYSTEM_STATUS_CANCELED, 0);
504 continue;
505 }
506
507 if (!children_finished)
508 {
509 // Still waiting for the children to finish
510 ++i;
511 continue;
512 }
513
514 // The item is selected and removed from the array
515 ctx->m_Work.Erase(i);
516 *out_item = item;
517 return hjob;
518 }
519 *out_item = 0;
520 return INVALID_JOB;
521}
522
523// Good for unit testing with/without threads enabled
524static void UpdateSingleThread(JobThreadContext* ctx, uint64_t max_time)

Callers 2

UpdateSingleThreadFunction · 0.85
JobThreadFunction · 0.85

Calls 4

GetJobItemFunction · 0.85
PutDoneFunction · 0.85
SizeMethod · 0.45
EraseMethod · 0.45

Tested by

no test coverage detected