home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / SRC / TIMER.MOD < prev    next >
Text File  |  1996-10-23  |  2KB  |  52 lines

  1. IMPLEMENTATION MODULE Timer;
  2.  
  3.         (********************************************************)
  4.         (*                                                      *)
  5.         (*                 Timed operations                     *)
  6.         (*                                                      *)
  7.         (*      Author:         P. Moylan                       *)
  8.         (*      Last edited:    23 October 1996                 *)
  9.         (*      Status:         Working                         *)
  10.         (*                                                      *)
  11.         (********************************************************)
  12.  
  13. FROM OS2 IMPORT
  14.     (* proc *)  DosSleep;
  15.  
  16. FROM Semaphores IMPORT
  17.     (* type *)  Semaphore,
  18.     (* proc *)  TimedWaitT;
  19.  
  20. (************************************************************************)
  21. (*                      "PUT-ME-TO-SLEEP" PROCEDURE                     *)
  22. (************************************************************************)
  23.  
  24. PROCEDURE Sleep (milliseconds: CARDINAL);
  25.  
  26.     (* Puts the caller to sleep for approximately the given number of   *)
  27.     (* milliseconds.                                                    *)
  28.  
  29.     BEGIN
  30.         DosSleep (milliseconds);
  31.     END Sleep;
  32.  
  33. (************************************************************************)
  34. (*                      SEMAPHORE WAIT WITH TIMEOUT                     *)
  35. (************************************************************************)
  36.  
  37. PROCEDURE TimedWait (s: Semaphore;  TimeLimit: INTEGER;
  38.                                         VAR (*OUT*) TimedOut: BOOLEAN);
  39.  
  40.     (* Like a semaphore Wait, except that it returns with TimedOut TRUE *)
  41.     (* if the corresponding Signal does not occur within TimeLimit      *)
  42.     (* milliseconds.                                                    *)
  43.  
  44.     BEGIN
  45.         TimedWaitT (s, TimeLimit, TimedOut);
  46.     END TimedWait;
  47.  
  48. (************************************************************************)
  49.  
  50. END Timer.
  51.  
  52.