From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,550291bc2bbf5019 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-17 07:19:55 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Multiple task bodies for one task type? Date: 17 Sep 2001 10:15:13 -0400 Organization: NASA Goddard Space Flight Center Message-ID: References: <3BA2A012.1C2A2903@san.rr.com> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1000736190 6816 128.183.220.71 (17 Sep 2001 14:16:30 GMT) X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov NNTP-Posting-Date: 17 Sep 2001 14:16:30 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Xref: archiver1.google.com comp.lang.ada:13123 Date: 2001-09-17T14:16:30+00:00 List-Id: Darren New writes: > What's the normal Ada idiom for having multiple types of task in an > array? There is no direct support for arrays of heterogeneous objects in Ada. You can have arrays of tagged types, and the concrete types can have different task objects: type base_type is abstract tagged null record; type base_access_type is access all base_type'class; type task_1_tagged_type is new base_type with record task_1 : task_1_type; end record; type task_2_tagged_type is new base_type with record task_2 : task_2_type; end record; type task_array_type is array (1 .. 10) of base_access_type; > Basically, I want a bunch of tasks where I can do something like > > tat : array (1..10) of mumble; > ta : tat; > begin > -- "perform" is an entry or a protected procedure > ta(1).perform(30); > ta(2).perform(30); > end > > and have the two calls execute different code. You can use task discriminants to execute different code (I forget the syntax, so I won't give an example). > Generally, I want to write a framework where these tasks act > something like callbacks, except I expect I'm going to want them to > actually be tasks and protected objects (probably one of each). You can use real callbacks; pass a subprogram pointer to each task in an Initialize rendezvous. > But it looks like each task type gets exactly one task body. Yes, but it can be parameterized by task attributes, or the entries can be parameterized by family parameters (again, I forget the syntax). > Of course, the primary problem is that things like "accept" and > "abort" and such have to actually be in the task body itself, not in > subprograms called from the task body, or I'd just make (say) a > generic with a procedure for each entry, or something. > > Any hints how one would go about this? Thanks in advance! Try writing a detailed example in illegal Ada that shows what you want, then we can help make it legal. -- -- Stephe