1. -- 
  2. -- Uwe R. Zimmer, Australia, July 2011 
  3. -- 
  4.  
  5. generic 
  6.  
  7.    type Element is private; 
  8.    type Buffer_Index is mod <>; 
  9.  
  10. package Generic_Realtime_Buffer is 
  11.  
  12.    pragma Elaborate_Body; 
  13.  
  14.    type Realtime_Buffer is private; 
  15.  
  16.    procedure Put (B : in out Realtime_Buffer; Item :     Element); 
  17.    procedure Get (B : in out Realtime_Buffer; Item : out Element); 
  18.  
  19.    function Element_Available (B : Realtime_Buffer) return Boolean; 
  20.  
  21.    Calling_Get_On_Empty_Buffer : exception; 
  22.  
  23. private 
  24.  
  25.    type No_Of_Elements is new Natural range 0 .. Natural (Buffer_Index'Last) + 1; 
  26.  
  27.    type Buffer_Array is array (Buffer_Index) of Element; 
  28.  
  29.    type Realtime_Buffer is record 
  30.       Write_To, 
  31.       Read_From          : Buffer_Index   := Buffer_Index'First; 
  32.       Elements_In_Buffer : No_Of_Elements := 0; 
  33.       Buffer             : Buffer_Array; 
  34.    end record; 
  35.  
  36. end Generic_Realtime_Buffer;