| 486 | } |
| 487 | |
| 488 | static 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 |
| 524 | static void UpdateSingleThread(JobThreadContext* ctx, uint64_t max_time) |
no test coverage detected