comp.lang.ada
 help / color / mirror / Atom feed
From: Larry Hazel <lhhazel@otelco.net>
Subject: Re: Dynamic dispatch again
Date: Mon, 08 Oct 2001 20:29:20 -0500
Date: 2001-10-08T20:29:20-05:00	[thread overview]
Message-ID: <3BC252F0.E806EFE1@otelco.net> (raw)
In-Reply-To: 3BC2475D.535D4E72@san.rr.com

Darren New wrote:
> 
> tmoran@acm.org wrote:
> >
> > >Right now, my alternative is ... .  Ugly.
> >   I've *always* found that if something was ugly/difficult in Ada,
> > after some thought it would become clear that the approach was in
> > fact a poor one, and a different approach, which worked nicely in
> > Ada, was a better one.  (Not to say that this alternative nice
> > approach in this case is obvious. ;)
> 
> Well, that's kind of why I'm posting here. I'm not sure what the right
> approach to dynamically dispatching an entry to one of N different tasks
> might be. Someone earlier mentioned using "requeue", but that seems to
> suffer the same problems. I've thought of any number of different
> approaches, and they're all ugly, since the point is to have a bunch of
> different tasks running, and all the alternate approaches involve not
> dealing with tasks.
> 
> It seems Ada isn't quite as orthogonal as could be hoped.

I'm not sure I understand what you are trying to do.  What I am going to suggest
is somewhat ugly to an Ada person and may be compiler dependent, but I don't
think so.  If the task specs are all the same:

with Unchecked_Conversion;
...
...
   task type A is
      -- common spec
   end A;
   type A_Access is access A;

   type Task_Array is array(1..How_Many) of A_Access;

   task type B is
      -- common spec
   end B;
   type B_Access is access B;

   function Coerce is new Unchecked_Conversion (B_Access, A_Access);

etc.

   Tasks : Task_Array := (new A, Coerce(new B), ....);

I've seen this work in Ada 83 with the VADS compiler.

Larry



  reply	other threads:[~2001-10-09  1:29 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
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 [this message]
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