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

Method finalize

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

Source from the content-addressed store, hash-verified

274}
275
276int JobQueue::finalize() SKR_NOEXCEPT
277{
278 // Queue as many JobFinalizeItems as the number of worker threads to finish the worker threads.
279 // Since the worker thread that received JobFinalizeItem will always end without taking the next Job,
280 // This will terminate all worker threads.
281 skr::stl_vector<JobFinalizeItem> finalJobs;
282 finalJobs.reserve(thread_list.size());
283 for (int i = 0; i < thread_list.size(); ++i)
284 {
285 finalJobs.emplace_back();
286 enqueueCore(&finalJobs.back(), /*isEndJob=*/true); // Normal enqueue will fail after this point
287 }
288
289 // wait for worker thread to finish。
290 for (auto *pWorkerThread : thread_list)
291 {
292 pWorkerThread->join();
293
294 SkrDelete(pWorkerThread->get_function());
295 SkrDelete(pWorkerThread);
296 }
297 thread_list.clear();
298
299 return ASYNC_RESULT_OK;
300}
301
302int JobQueue::enqueue(JobItem* jobItem) SKR_NOEXCEPT
303{

Callers 2

service_thread.cppFile · 0.45
exitMethod · 0.45

Calls 8

SkrDeleteFunction · 0.85
get_functionMethod · 0.80
reserveMethod · 0.45
sizeMethod · 0.45
emplace_backMethod · 0.45
backMethod · 0.45
joinMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected