MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / push

Method push

modules/core/core/src/async/job.cpp:47–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45 }
46
47 JobResult push(JobItem* jobItem, bool isEndJob = false)
48 {
49 cond->lock();
50 const auto endJobEnqueud = skr_atomic32_load_acquire(&is_end_job_queued);
51 if (endJobEnqueud && !isEndJob)
52 {
53 cond->unlock();
54 return ASYNC_RESULT_ERROR_INVALID_STATE;
55 }
56
57 // update the status of JobItem together with the state of the queue
58 skr_atomic32_store_release(&jobItem->status, isEndJob ? kJobItemStatusFinishJob : kJobItemStatusWaiting);
59 list_runnable.emplace_back(jobItem);
60
61 // end job is queued, only end job is accepted
62 skr_atomic32_store_release(&is_end_job_queued, isEndJob);
63
64 const auto c = skr_atomic32_load_acquire(&waiting_workers_count);
65 if (c)
66 {
67 cond->signal();
68 }
69
70 cond->unlock();
71
72 return ASYNC_RESULT_OK;
73 }
74
75 void erase(JobItem* jobItem)
76 {

Callers 1

enqueueCoreMethod · 0.45

Calls 6

signalMethod · 0.80
lockMethod · 0.45
unlockMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected