--  A bounded buffer between tasks: a protected object whose entries wait while it is full
--  (Put) or empty (Get), and a flag the consumer raises when it has read everything.
package Buffers is
   Size : constant := 4;
   type Index is mod Size;
   type Item_Array is array (Index) of Integer;

   protected Buffer is
      entry Put (X : Integer);
      entry Get (X : out Integer);
   private
      Items : Item_Array := (others => 0);
      First : Index := 0;
      Count : Natural := 0;
   end Buffer;

   protected Phase is
      procedure Finish;
      entry Wait_Finished;
   private
      Finished : Boolean := False;
   end Phase;
end Buffers;
