Inspirel banner

Programming Distributed Systems with YAMI4

4.3.22 Ada

Creating an agent object in Ada with 5 dispatcher tasks instead of default one can be achieved with the following code:

with YAMI.Agents;       use YAMI.Agents;
with YAMI.Option_Names; use YAMI.Option_Names;
with YAMI.Parameters;   use YAMI.Parameters;
-- ...

declare
   Options : Parameter_Collection := Make_Parameters;
begin
   Options.Set_Integer (Dispatcher_Threads, 5);

   declare
      My_Agent : Agent := Make_Agent (Options);
   begin
      --  ...
   end;
end;

The Option_Names package defines convenient string constants for all available configuration options.

Any subset of options can be used in a single parameters object and those options which are not provided are considered to have their default values.

No parameters object needs to be provided if all-default setup is intended, as shown in the following example:

with YAMI.Agents; use YAMI.Agents;
-- ...

declare
   My_Agent : Agent := Make_Agent;
begin
   --  ...
end;