5410543f49
git-svn-id: svn://kolibrios.org@9210 a494cfbc-eb01-0410-851d-a64ba20cac60
80 lines
1.6 KiB
Plaintext
80 lines
1.6 KiB
Plaintext
(*
|
|
Copyright 2021 Anton Krotov
|
|
|
|
This file is part of CEdit.
|
|
|
|
CEdit is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
CEdit is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with CEdit. If not, see <http://www.gnu.org/licenses/>.
|
|
*)
|
|
|
|
MODULE Timer;
|
|
|
|
IMPORT SYSTEM, K := KolibriOS, KOSAPI, Ini;
|
|
|
|
VAR
|
|
stack: ARRAY 1024*64 OF INTEGER;
|
|
ID*, n*, time, cnt: INTEGER;
|
|
enabled: BOOLEAN;
|
|
msg: ARRAY 3 OF INTEGER;
|
|
|
|
|
|
PROCEDURE kill*;
|
|
BEGIN
|
|
enabled := FALSE;
|
|
INC(n)
|
|
END kill;
|
|
|
|
|
|
PROCEDURE [stdcall] main (mainTID: INTEGER);
|
|
CONST
|
|
step = 5;
|
|
BEGIN
|
|
msg[0] := ID;
|
|
msg[1] := 12;
|
|
WHILE TRUE DO
|
|
K.Pause(step);
|
|
IF KOSAPI.sysfunc3(18, 21, mainTID) = 0 THEN
|
|
ID := 0;
|
|
K.Exit
|
|
END;
|
|
IF enabled THEN
|
|
DEC(cnt, step);
|
|
IF cnt <= 0 THEN
|
|
K.SendIPC(mainTID, msg);
|
|
cnt := time
|
|
END
|
|
END
|
|
END
|
|
END main;
|
|
|
|
|
|
PROCEDURE create* (mainTID: INTEGER);
|
|
BEGIN
|
|
time := Ini.blink;
|
|
cnt := time;
|
|
enabled := TRUE;
|
|
IF ID = 0 THEN
|
|
stack[LEN(stack) - 1] := mainTID;
|
|
ID := K.CreateThread(SYSTEM.ADR(main), stack)
|
|
ELSE
|
|
INC(n);
|
|
msg[2] := n
|
|
END
|
|
END create;
|
|
|
|
|
|
BEGIN
|
|
ID := 0;
|
|
msg[2] := 0;
|
|
n := 0;
|
|
END Timer. |