home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / DEF / CIRCULAR.DEF < prev    next >
Text File  |  1993-12-07  |  1KB  |  43 lines

  1. DEFINITION MODULE CircularBuffers;
  2.  
  3.     (****************************************************************)
  4.     (*                                *)
  5.     (*    Circular Buffer for passing character data        *)
  6.     (*        between a pair of tasks.            *)
  7.     (*                                *)
  8.     (*    Author:        P. Moylan                *)
  9.     (*    Last edited:    7 December 1993                *)
  10.     (*                                *)
  11.     (*    Status:        OK.                    *)
  12.     (*                                *)
  13.     (****************************************************************)
  14.  
  15. TYPE CircularBuffer;    (* is private *)
  16.  
  17. PROCEDURE CreateBuffer (VAR (*OUT*) B: CircularBuffer;  size: CARDINAL);
  18.  
  19.     (* Allocates space for a circular buffer, and initializes it.  The    *)
  20.     (* caller specifies how many characters the buffer will hold.    *)
  21.  
  22. PROCEDURE PutBuffer (B: CircularBuffer; item: CHAR);
  23.  
  24.     (* Waits for space available, then puts item at the tail of the queue. *)
  25.  
  26. PROCEDURE PutBufferImpatient (B: CircularBuffer;  item: CHAR;
  27.                         TimeLimit: CARDINAL);
  28.  
  29.     (* Like PutBuffer, but waits no longer than TimeLimit milliseconds    *)
  30.     (* for a buffer slot to become available.  If the time limit    *)
  31.     (* expires, the oldest item in the buffer is overwritten by the    *)
  32.     (* new data.                            *)
  33.  
  34. PROCEDURE GetBuffer (B: CircularBuffer) : CHAR;
  35.  
  36.     (* Takes one character from the head of the queue, waiting if necessary. *)
  37.  
  38. PROCEDURE BufferEmpty (B: CircularBuffer): BOOLEAN;
  39.  
  40.     (* Returns TRUE iff the buffer is empty. *)
  41.  
  42. END CircularBuffers.
  43.