问题
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