package body Pools is
   protected body Counter is
      procedure Add (N : Natural) is
      begin
         if Total <= Natural'Last - N then
            Total := Total + N;
         end if;
      end Add;

      entry Wait_Full (Total_Now : out Natural) when Total >= Goal is
      begin
         Total_Now := Total;
      end Wait_Full;
   end Counter;

   --  each worker adds its Id ten times to Small, and ten times its Id to Large
   task body Worker is
   begin
      for I in 1 .. 10 loop
         Small.Add (Id);
         Large.Add (Id * 10);
      end loop;
      loop
         delay 1.0;
      end loop;
   end Worker;
end Pools;
