X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/cda2e4bba1a2bc9bd3e48076f236ac843086aff3..8bc22a17b97149d69fd377f5e9f5ed617a4385db:/lcore.pas?ds=sidebyside diff --git a/lcore.pas b/lcore.pas index 097ea79..08c242a 100644 --- a/lcore.pas +++ b/lcore.pas @@ -225,7 +225,7 @@ procedure exitmessageloop; var firsttimer : tltimer ; - firsttask , lasttask , currenttask : tltask ; + firsttask , lasttask : tltask ; numread : integer ; mustrefreshfds : boolean ; @@ -669,7 +669,7 @@ end; {$ifndef mswindows} procedure tltimer.resettimes; begin - gettimeofday(nextts); + gettimemonotonic(nextts); {if not initialevent then} tv_add(nextts,interval); end; {$endif} @@ -813,26 +813,18 @@ end; procedure processtasks;//inline; var - temptask : tltask ; - + currenttask:tltask; begin - if not assigned(currenttask) then begin + while assigned(firsttask) do begin currenttask := firsttask; - firsttask := nil; - lasttask := nil; - end; - while assigned(currenttask) do begin + firsttask := firsttask.nexttask; + if not assigned(firsttask) then lasttask := nil; if assigned(currenttask.handler) then currenttask.handler(currenttask.wparam,currenttask.lparam); - if assigned(currenttask) then begin - temptask := currenttask; - currenttask := currenttask.nexttask; - temptask.free; - end; - //writeln('processed a task'); + currenttask.free; end; - + currenttask := nil; end; @@ -841,23 +833,18 @@ end; procedure disconnecttasks(aobj:tobject); var currenttasklocal : tltask ; - counter : byte ; + begin - for counter := 0 to 1 do begin - if counter = 0 then begin - currenttasklocal := firsttask; //main list of tasks - end else begin - currenttasklocal := currenttask; //needed in case called from a task - end; - // note i don't bother to destroy the links here as that will happen when - // the list of tasks is processed anyway - while assigned(currenttasklocal) do begin - if currenttasklocal.obj = aobj then begin - currenttasklocal.obj := nil; - currenttasklocal.handler := nil; - end; - currenttasklocal := currenttasklocal.nexttask; + currenttasklocal := firsttask; //main list of tasks + + // note i don't bother to destroy the links here as that will happen when + // the list of tasks is processed anyway + while assigned(currenttasklocal) do begin + if currenttasklocal.obj = aobj then begin + currenttasklocal.obj := nil; + currenttasklocal.handler := nil; end; + currenttasklocal := currenttasklocal.nexttask; end; end;