libDispatch serving RunOnMainQueueDelayed from Java

别等时光非礼了梦想. 提交于 2019-12-11 12:59:56

问题


I am using libDispatch (GCD) opensource on Android platform. So, most of the complex time consuming tasks are being done through NDK (where i am using libDispatch).

I am scheduling some tasks with delay on the MainQueue using the function RunOnMainQueueDelayed. To run the main queue tasks I am running a timer of 15ms on java side and whenever timer expires I run a JNI call which will run the function _dispatch_main_queue_callback_4CF on native side so tht the tasks on the mainqueue gets executed.

Now the problem I am facing is that if I am providing a delay in mainqueue which is less than ~15ms than the task get executed. But if the delay is more than 15 ms or the task is scheduled on the queue after the execution of at least one task than none of the tasks get executed.

I am not able to understand the reason of this weird behaviour of the MainQueue.I tried to debug the code of libdispatch but could not find the reason.

Someone please how does the mainQueue works and what could be the reason of this issue.

来源:https://stackoverflow.com/questions/34924507/libdispatch-serving-runonmainqueuedelayed-from-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!