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

Function JobSystemSetParent

engine/dlib/src/dlib/jobsystem.cpp:219–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219JobSystemResult JobSystemSetParent(HJobContext context, HJob hchild, HJob hparent)
220{
221 JobThreadContext* ctx = &context->m_ThreadContext;
222 DM_MUTEX_OPTIONAL_SCOPED_LOCK(ctx->m_Mutex);
223
224 JobItem* item = CheckItem(ctx, hchild);
225 JobItem* parent = CheckItem(ctx, hparent);
226
227 assert(item->m_Status == JOBSYSTEM_STATUS_CREATED);
228 assert(parent->m_Status <= JOBSYSTEM_STATUS_QUEUED); // If it has started to process, it's too late
229
230 // You should only call setparent once per task
231 assert(item->m_Parent == INVALID_JOB);
232 assert(item->m_Sibling == INVALID_JOB);
233
234 item->m_Parent = hparent;
235 item->m_Sibling = INVALID_JOB;
236 if (parent->m_FirstChild == INVALID_JOB)
237 {
238 parent->m_FirstChild = hchild;
239 parent->m_LastChild = hchild;
240 }
241 else
242 {
243 JobItem* last_child = GetJobItem(ctx, parent->m_LastChild);
244 last_child->m_Sibling = hchild;
245 parent->m_LastChild = hchild;
246 }
247 dmAtomicIncrement32(&parent->m_NumChildren);
248
249 // TODO: Make sure all the children inherit the priority of the parent
250
251 return JOBSYSTEM_RESULT_OK;
252}
253
254HJob JobSystemCreateJob(HJobContext context, Job* job)
255{

Callers 2

TEST_PFunction · 0.85
GenerateGlyphJobByIndexFunction · 0.85

Calls 4

CheckItemFunction · 0.85
GetJobItemFunction · 0.85
dmAtomicIncrement32Function · 0.85
assertFunction · 0.50

Tested by 1

TEST_PFunction · 0.68