1. package body Generic_Realtime_Buffer is 
  2.  
  3.    --------- 
  4.    -- Put -- 
  5.    --------- 
  6.  
  7.    procedure Put (B : in out Realtime_Buffer; Item : Element) is 
  8.  
  9.    begin 
  10.       if B.Elements_In_Buffer = No_Of_Elements'Last then 
  11.          B.Read_From := B.Read_From + 1; 
  12.       else 
  13.          B.Elements_In_Buffer := B.Elements_In_Buffer + 1; 
  14.       end if; 
  15.       B.Buffer (B.Write_To) := Item; 
  16.       B.Write_To := B.Write_To + 1; 
  17.    end Put; 
  18.  
  19.    --------- 
  20.    -- Get -- 
  21.    --------- 
  22.  
  23.    procedure Get (B : in out Realtime_Buffer; Item : out Element) is 
  24.  
  25.    begin 
  26.       if B.Elements_In_Buffer > 0 then 
  27.          Item                 := B.Buffer (B.Read_From); 
  28.          B.Read_From          := B.Read_From + 1; 
  29.          B.Elements_In_Buffer := B.Elements_In_Buffer - 1; 
  30.       else 
  31.          raise Calling_Get_On_Empty_Buffer; 
  32.       end if; 
  33.    end Get; 
  34.  
  35.    ----------------------- 
  36.    -- Element_Available -- 
  37.    ----------------------- 
  38.  
  39.    function Element_Available (B : Realtime_Buffer) return Boolean is 
  40.  
  41.    begin 
  42.       return B.Elements_In_Buffer > 0; 
  43.    end Element_Available; 
  44.  
  45. end Generic_Realtime_Buffer;