I am at loss after spending hours on this.
Protected type declaration:
protected type AdditionMachine is
procedure setTask (Item : in WorkerTask);
procedure getTask (Item : out WorkerTask);
procedure calculate;
private
machineType : String (1 .. 1) := "A";
job : workerTask;
end AdditionMachine;
Task:
task body SimpleTask1 is
Available : Natural := ADDITION_MACHINES;
Elements : array (1 .. ADDITION_MACHINES) of AdditionMachine;
begin
loop
select
when Available > 0 =>
accept getMachine (machine : out AdditionMachine) do
machine := Elements(Available);
Available := Available - 1;
end getMachine;
or
accept addMachine (machine : in AdditionMachine) do
Available := Available + 1;
Elements(Available) := machine;
end addMachine;
end select;
end loop;
end SimpleTask1;
At line Elements(Available) := machine;
and machine := Elements(Available);
I get "left hand of assingment must not be limited type"
I have no idea how to fix this, I've found nothing when I googled, can anyone help?
edit: I now know that protected types are limited, but how do I accomplish a pool of protected objects without something like above?