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

Function JobThread

engine/dlib/src/dlib/jobsystem.cpp:546–577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

544
545#if defined(DM_HAS_THREADS)
546static void JobThread(void* _ctx)
547{
548 JobThreadContext* ctx = (JobThreadContext*)_ctx;
549 while (true)
550 {
551 HJob hjob = 0;
552 {
553 DM_MUTEX_SCOPED_LOCK(ctx->m_Mutex);
554
555 if (!ctx->m_Run)
556 break;
557
558 while(ctx->m_Work.Empty())
559 {
560 dmConditionVariable::Wait(ctx->m_WakeupCond, ctx->m_Mutex);
561 if (!ctx->m_Run)
562 return;
563 }
564
565 uint64_t time = dmTime::GetMonotonicTime();
566 JobItem* item = 0;
567 hjob = SelectAndPopJob(ctx, time, &item);
568 if (hjob == INVALID_JOB)
569 continue;
570 }
571
572 {
573 DM_PROFILE("JobThreadProcess");
574 ProcessOneJob(ctx, hjob);
575 }
576 }
577}
578#endif
579
580static void ProcessFinishedJobs(HJobContext context, jc::RingBuffer<HJob>& items)

Callers

nothing calls this directly

Calls 5

SelectAndPopJobFunction · 0.85
ProcessOneJobFunction · 0.85
WaitFunction · 0.70
GetMonotonicTimeFunction · 0.70
EmptyMethod · 0.45

Tested by

no test coverage detected