From: tmoran@acm.org
Subject: Re: Dynamic dispatch again
Date: Sat, 06 Oct 2001 17:52:30 GMT
Date: 2001-10-06T17:52:30+00:00 [thread overview]
Message-ID: <yxHv7.8404$IY3.6643465@news1.rdc1.sfba.home.com> (raw)
In-Reply-To: 3BBE5993.1CF0069D@san.rr.com
>OK, I'm still trying to figure out how to make one entry call wind up
>calling code in different units.
>...
>Essentially, I have a basic manager task doing I/O, distributing
>messages to "profiles". Each "profile" can get the same set of messages
>(start, stop, are you ready, here's a message), but each responds to the
>messages in different ways.
How about having a single "profile" task, and using tagged type "methods"
to respond in different ways, eg:
package profile is
type changeable_content is abstract tagged limited null record;
type changeable_content_pointer is access all changeable_content'class;
procedure xlate_content(what_to_do : in changeable_content;
in_in : in integer; out_out : out integer)
is abstract;
task type general_task(content : changeable_content_pointer) is
entry xlate(in_in : in integer; out_out : out integer);
end general_task;
type general_task_pointer is access general_task;
end profile;
package body profile is
task body general_task is
begin
loop
select
accept xlate(in_in : in integer; out_out : out integer)
do
xlate_content(content.all, in_in, out_out);
end xlate;
or
terminate;
end select;
end loop;
end general_task;
end profile;
with profile;
package double is
type content is new profile.changeable_content with null record;
procedure xlate_content(what_to_do : in content;
in_in : in integer; out_out : out integer);
end double;
package body double is
procedure xlate_content(what_to_do : in content;
in_in : in integer; out_out : out integer) is
begin
out_out := in_in + in_in;
end xlate_content;
end double;
with profile;
package negate is
type content is new profile.changeable_content with null record;
procedure xlate_content(what_to_do : in content;
in_in : in integer; out_out : out integer);
end negate;
package body negate is
procedure xlate_content(what_to_do : in content;
in_in : in integer; out_out : out integer) is
begin
out_out := - in_in;
end xlate_content;
end negate;
with profile;
with double;
with negate;
with Ada.Text_IO;
procedure driver is
type pat is array(1..2) of profile.general_task_pointer;
pa : pat;
i : integer;
doubler : profile.changeable_content_pointer := new double.content;
negater : profile.changeable_content_pointer := new negate.content;
begin
pa(1) := new profile.general_task(doubler);
pa(2) := new profile.general_task(negater);
pa(1).xlate(100, i);
Ada.Text_IO.Put_Line("First, " & Integer'Image(I));
pa(2).xlate(100, i);
Ada.Text_IO.Put_Line("Second, " & Integer'Image(I));
end driver;
next prev parent reply other threads:[~2001-10-06 17:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-06 1:08 Dynamic dispatch again Darren New
2001-10-06 17:52 ` tmoran [this message]
2001-10-08 1:13 ` Darren New
2001-10-08 4:23 ` tmoran
2001-10-08 16:26 ` Darren New
2001-10-08 18:21 ` tmoran
2001-10-08 19:07 ` Darren New
2001-10-09 0:25 ` tmoran
2001-10-09 0:40 ` Darren New
2001-10-09 1:29 ` Larry Hazel
2001-10-09 4:10 ` tmoran
2001-10-09 15:40 ` Darren New
2001-10-09 17:58 ` tmoran
2001-10-09 19:26 ` Darren New
2001-10-09 19:42 ` tmoran
2001-10-09 20:23 ` Darren New
2001-10-09 22:37 ` tmoran
2001-10-10 18:17 ` Darren New
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox