This commit is contained in:
Coder12a 2018-11-26 22:48:19 -06:00
parent 1f915850d9
commit b9a64f723c
2 changed files with 7 additions and 10 deletions

View File

@ -75,7 +75,7 @@ function extended_api.Async.iterate(pool,from,to,func,callback)
local maxtime = pool.maxtime local maxtime = pool.maxtime
for i = from, to do for i = from, to do
local b = func(i) local b = func(i)
if b and b == false then if b ~= nil and b == false then
break break
end end
if minetest.get_us_time() * 1000 > last_time + maxtime then if minetest.get_us_time() * 1000 > last_time + maxtime then
@ -96,7 +96,7 @@ function extended_api.Async.foreach(pool,array, func, callback)
local maxtime = pool.maxtime local maxtime = pool.maxtime
for k,v in ipairs(array) do for k,v in ipairs(array) do
local b = func(k,v) local b = func(k,v)
if b and b == false then if b ~= nil and b == false then
break break
end end
if minetest.get_us_time() * 1000 > last_time + maxtime then if minetest.get_us_time() * 1000 > last_time + maxtime then
@ -117,7 +117,7 @@ function extended_api.Async.do_while(pool,condition_func, func, callback)
local maxtime = pool.maxtime local maxtime = pool.maxtime
while(condition_func()) do while(condition_func()) do
local c = func() local c = func()
if c and c ~= condition_func() then if c ~= nil and c ~= condition_func() then
break break
end end
if minetest.get_us_time() * 1000 > last_time + maxtime then if minetest.get_us_time() * 1000 > last_time + maxtime then
@ -137,10 +137,7 @@ function extended_api.Async.register_globalstep(pool,func)
local last_time = minetest.get_us_time() * 1000 local last_time = minetest.get_us_time() * 1000
local dtime = last_time local dtime = last_time
while(true) do while(true) do
local c = func(dtime) func(dtime)
if c and c == false then
break
end
dtime = minetest.get_us_time() * 1000 dtime = minetest.get_us_time() * 1000
-- 0.05 seconds -- 0.05 seconds
if minetest.get_us_time() * 1000 > last_time + 50 then if minetest.get_us_time() * 1000 > last_time + 50 then
@ -159,7 +156,7 @@ function extended_api.Async.chain_task(pool,tasks,callback)
local maxtime = pool.maxtime local maxtime = pool.maxtime
for index, task_func in pairs(tasks) do for index, task_func in pairs(tasks) do
local p = task_func(pass_arg) local p = task_func(pass_arg)
if p then if p ~= nil then
pass_arg = p pass_arg = p
end end
if minetest.get_us_time() * 1000 > last_time + maxtime then if minetest.get_us_time() * 1000 > last_time + maxtime then
@ -188,7 +185,7 @@ function extended_api.Async.queue_task(pool,func,callback)
if task_func and task_func.func then if task_func and task_func.func then
pass_arg = nil pass_arg = nil
local p = task_func.func(pass_arg) local p = task_func.func(pass_arg)
if p then if p ~= nil then
pass_arg = p pass_arg = p
end end
if task_func.callback then if task_func.callback then

View File

@ -385,7 +385,7 @@ local function iterate(db,func_on_iterate,end_func,count,cs,args)
local line = fl:read("*l") local line = fl:read("*l")
if args.do_not_skip_removed_items or not db.indexes_pool[cs].deleted_items[line] then if args.do_not_skip_removed_items or not db.indexes_pool[cs].deleted_items[line] then
local ar = func_on_iterate(line,i,args) local ar = func_on_iterate(line,i,args)
if ar then if ar ~= nil then
args = ar args = ar
return args return args
end end