Adaで次のタスクを作成していますが、私のバッファのカウントを教えてくれるプロシージャが含まれています。どうやってやるの?Adaタスクのプロシージャまたはファンクションを作成する
package body Buffer is
task body Buffer is
size: constant := 10000; -- buffer capacity
buf: array(1.. size) of Types.Item;
count: integer range 0..size := 0;
in_index,out_index:integer range 1..size := 1;
begin
procedure getCount(currentCount: out Integer) is
begin
currentCount := count;
end getCount;
loop
select
when count<size =>
accept put(item: in Types.Item) do
buf(in_index) := item;
end put;
in_index := in_index mod size+1;
count := count + 1;
or
when count>0 =>
accept get(item:out Types.Item) do
item := buf(out_index);
end get;
out_index := out_index mod size+1;
count := count - 1;
or
terminate;
end select;
end loop;
end Buffer;
end Buffer;
私はこのコードをコンパイルするとき、私は
宣言は
getCount
プロシージャの定義を参照
を「開始」の前に来なければならないというエラーが発生します。
+1よく目に付きます。 @Keith Thompsonの改良された書式設定が、これをもっと簡単に見えるのは魅力的です。 – trashgod