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

Method process_main_thread_dispatch_queue_for

utility/task_manager.cpp:408–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406}
407
408void TaskManager::process_main_thread_dispatch_queue_for(int64_t time_usec) {
409 if (!Thread::is_main_thread()) {
410 return;
411 }
412 int64_t start_time_usec = OS::get_singleton()->get_ticks_usec();
413 int64_t elapsed_time_usec = 0;
414 while (elapsed_time_usec < time_usec) {
415 std::shared_ptr<BaseMainThreadDispatchData> data;
416 if (!main_thread_dispatch_queue.try_pop(data)) {
417 break;
418 }
419 TaskManagerID previous_main_thread_task_id = main_thread_task_id;
420 if (previous_main_thread_task_id == data->get_calling_task_id()) {
421 WARN_PRINT("Trying to dispatch to the same task id, this is not supported!");
422 }
423 set_thread_task_id(data->get_calling_task_id());
424 data->callback();
425 set_thread_task_id(previous_main_thread_task_id);
426 elapsed_time_usec = OS::get_singleton()->get_ticks_usec() - start_time_usec;
427 }
428}
429
430void TaskManager::cancel_main_thread_dispatch_queue() {
431 if (!Thread::is_main_thread()) {

Callers

nothing calls this directly

Calls 3

get_calling_task_idMethod · 0.80
callbackMethod · 0.80
try_popMethod · 0.45

Tested by

no test coverage detected