MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / main_loop

Method main_loop

utility/task_manager.cpp:543–584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

541}
542
543void TaskManager::DownloadQueueThread::main_loop() {
544 while (running) {
545 DownloadTaskID item;
546 if (!queue.try_pop(item)) {
547 // if (!waiting) {
548 // TaskManager::get_singleton()->update_progress_bg();
549 // }
550 OS::get_singleton()->delay_usec(10000);
551 continue;
552 }
553 std::shared_ptr<DownloadTaskData> task;
554 tasks.if_contains(item, [&](auto &v) {
555 task = v.second;
556 if (task) {
557 MutexLock lock(worker_mutex);
558 running_task = task;
559 worker_cv.notify_all();
560 }
561 });
562 ERR_CONTINUE_MSG(!task, "Download task ID " + itos(item) + " not found");
563 while (!task->is_done() && !task->is_waiting) {
564 task->update_progress();
565 OS::get_singleton()->delay_usec(10000);
566 }
567 while (!task->is_done()) {
568 OS::get_singleton()->delay_usec(10000);
569 }
570 if (!task->is_waiting) {
571 task->finish_progress();
572 }
573 if (task->is_canceled()) {
574 // pop off the rest of the queue
575 MutexLock lock(write_mutex);
576 tasks.for_each_m([&](auto &v) {
577 v.second->cancel();
578 });
579 tasks.clear();
580 while (queue.try_pop(item)) {
581 }
582 }
583 }
584}
585
586TaskManager::DownloadTaskID TaskManager::DownloadQueueThread::add_download_task(const String &p_download_url, const String &p_save_path, bool silent) {
587 MutexLock lock(write_mutex);

Callers 1

thread_funcMethod · 0.80

Calls 9

if_containsMethod · 0.80
update_progressMethod · 0.80
finish_progressMethod · 0.80
for_each_mMethod · 0.80
try_popMethod · 0.45
is_doneMethod · 0.45
is_canceledMethod · 0.45
cancelMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected