Char : Character;
begin
loop
... -- produce the next character Char
Buffer.Write(Char);
exit when Char = ASCII.EOT;
end loop;
end Producer;
Char : Character;
begin
loop
Buffer.Read(Char);
exit when Char = ASCII.EOT;
... -- consume the character Char
end loop;
end Consumer;
entry Read (C : out Character);
entry Write(C : in Character);
private
Pool : String(1 .. 100);
Count : Natural := 0;
In_Index, Out_Index : Positive := 1;
end Buffer;
entry Write(C : in Character)
when Count < Pool'Length is
begin
Pool(In_Index) := C;
In_Index := (In_Index mod Pool'Length) + 1;
Count := Count + 1;
end Write;
when Count > 0 is
begin
C := Pool(Out_Index);
Out_Index := (Out_Index mod Pool'Length) + 1;
Count := Count - 1;
end Read;
end Buffer;