即使事件型任务,也可能有较长的执行时间,不能在Sleep里面安排调度。

任务轮询调度后,Sleep状态时不能睡眠,至少也要判断阀值
This commit is contained in:
Stone 2016-06-21 04:13:45 +00:00
parent 4922a950ae
commit 72aadaa942
1 changed files with 2 additions and 2 deletions

View File

@ -105,7 +105,7 @@ bool Task::CheckTime(UInt64 end, bool isSleep)
if(NextTime > 0 && NextTime > now) return false;
// 事件型任务并且当前可用时间超过10ms允许调度
if(Event && now + 10 < end) return true;
//if(Event && now + 10 < end) return true;
// 并且任务的平均耗时要足够调度才安排执行避免上层是Sleep时超出预期时间
if(now + CostMs > end) return false;
@ -320,7 +320,7 @@ void TaskScheduler::Execute(uint msMax, bool& cancel)
// 如果有最小时间,睡一会吧
now = Sys.Ms(); // 当前时间
if(/*msMax == 0xFFFFFFFF &&*/ min != UInt64_Max && min > now)
if(msMax == 0xFFFFFFFF && min != UInt64_Max && min > now)
{
min -= now;
//debug_printf("任务空闲休眠 %d ms \r\n", (uint)(min/1000));