| 406 | } |
| 407 | |
| 408 | void 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 | |
| 430 | void TaskManager::cancel_main_thread_dispatch_queue() { |
| 431 | if (!Thread::is_main_thread()) { |
nothing calls this directly
no test coverage detected