@ -1178,16 +1178,15 @@ function UIManager:_checkTasks()
-- task.action may schedule other events
-- task.action may schedule other events
self._task_queue_dirty = false
self._task_queue_dirty = false
while true do
while true do
local nu_task = # self._task_queue
if # self._task_queue == 0 then
if nu_task == 0 then
-- Nothing to do!
-- all tasks checked
break
break
end
end
local task = self._task_queue [ 1 ]
local next_ task = self._task_queue [ 1 ]
local task_tv = task.time or TimeVal.zero
local task_tv = next_ task.time or TimeVal.zero
if task_tv <= self._now then
if task_tv <= self._now then
-- remove from table
-- remove from table
table.remove ( self._task_queue , 1 )
local task = table.remove ( self._task_queue , 1 )
-- task is pending to be executed right now. do it.
-- task is pending to be executed right now. do it.
-- NOTE: be careful that task.action() might modify
-- NOTE: be careful that task.action() might modify
-- _task_queue here. So need to avoid race condition
-- _task_queue here. So need to avoid race condition
@ -1195,7 +1194,7 @@ function UIManager:_checkTasks()
else
else
-- queue is sorted in ascendant order, safe to assume all items
-- queue is sorted in ascendant order, safe to assume all items
-- are future tasks for now
-- are future tasks for now
wait_until = task.time
wait_until = next_ task.time
break
break
end
end
end
end