fix alarm calculation

This commit is contained in:
Daniel Poelzleithner 2022-04-19 20:32:33 +02:00
parent a244d49ea4
commit a60cf7c541
1 changed files with 17 additions and 9 deletions

View File

@ -2933,26 +2933,34 @@ local Sync = ( function
end end
-- first checks if more processes could be spawned -- first checks if more processes could be spawned
if self.processes:size( ) < self.config.maxProcesses if self.processes:size( ) > self.config.maxProcesses
then then
-- finds the nearest delay waiting to be spawned return false
for _, d in self.delays:qpairs( ) end
do
if d.status == 'wait' -- finds the nearest delay waiting to be spawned
then for _, d in self.delays:qpairs( )
if rv == false or d.alarm < rv then do
print("alarm", alarm2string(d.alarm), type(d.alarm))
if d.status == 'wait'
then
if type(d.alarm) == "boolean" and d.alarm == true then
return true
end
if type(d.alarm) == "userdata" then
if rv == false or
d.alarm < rv then
rv = d.alarm rv = d.alarm
end end
end end
end end
end end
if rv == false and self.nextCronAlarm ~= false then if rv == false and self.nextCronAlarm ~= false then
rv = self.nextCronAlarm rv = self.nextCronAlarm
elseif rv == true then
elseif self.nextCronAlarm ~= false and self.nextCronAlarm < rv then elseif self.nextCronAlarm ~= false and self.nextCronAlarm < rv then
rv = self.nextCronAlarm rv = self.nextCronAlarm
end end
-- nothing to spawn -- nothing to spawn
return rv return rv
end end