DEFINITION MODULE Watchdog;

        (********************************************************)
        (*                                                      *)
        (*             Times out inactive sessions              *)
        (*                                                      *)
        (*  Programmer:         P. Moylan                       *)
        (*  Started:            27 December 2017                *)
        (*  Last edited:        9 April 2025                    *)
        (*  Status:             OK                              *)
        (*                                                      *)
        (*  Change 2021-09-16: removed the second parameter     *)
        (*  from RemoveFromWatches, because it was always TRUE. *)
        (*                                                      *)
        (********************************************************)



FROM SYSTEM IMPORT ADDRESS;
FROM TransLog IMPORT TransactionLogID;


TYPE
    WatchdogID;                     (* is private*)
    PROC1 = PROCEDURE (ADDRESS);



PROCEDURE AddToWatches (seconds: CARDINAL;   logID: TransactionLogID;
                        handler: PROC1;  arg: ADDRESS): WatchdogID;

    (* Adds a new thread to be watched.  If the thread times out,   *)
    (* handler(arg) is called.                                      *)

PROCEDURE RemoveFromWatches (VAR (*INOUT*) ID: WatchdogID);

    (* Removes this entry from the watchdog list if it is still on  *)
    (* the list, and discards it.                                   *)

PROCEDURE KickWatchdog (ID: WatchdogID);

    (* Tells the watchdog that this entry is still active. *)

END Watchdog.

