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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8a3e2ce4e6d56336 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-08 20:24:07 PST Path: supernews.google.com!sn-xit-03!supernews.com!freenix!enst!enst.fr!not-for-mail From: "Beard, Frank" Newsgroups: comp.lang.ada Subject: RE: Generic Formal Parameter for a Task Type Date: Thu, 8 Mar 2001 23:20:12 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: avanie.enst.fr 984111733 81295 137.194.161.2 (9 Mar 2001 04:22:13 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Fri, 9 Mar 2001 04:22:13 +0000 (UTC) To: "'comp.lang.ada@ada.eu.org'" Return-Path: X-Mailer: Internet Mail Service (5.5.2448.0) Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: supernews.google.com comp.lang.ada:5561 Date: 2001-03-08T23:20:12-05:00 Why can't you have something like the following: generic type Item is limited private; with function Terminated(the_Item : Item) return boolean; package Xyz is procedure Monitor(the_Item : Item); ... end Xyz; You instantiate the package with the task type and supply the Terminated function, which would look something like: function Terminated(the_Task : Task_Type) return boolean is begin return the_Task'terminated; end Terminated; So, inside your generic where you are monitoring the task, you call the supplied function. Of course, you would have to supply a function for every task attribute you wanted to check. I know it's not as clean as using the attribute directly, but it's not that bad. I haven't tried to test this but the spec part compiles and it seems like it should work, but I might be missing something. Frank -----Original Message----- From: James Rogers [mailto:jimmaureenrogers@worldnet.att.net] Sent: Thursday, March 08, 2001 10:35 PM To: comp.lang.ada@ada.eu.org Subject: Re: Generic Formal Parameter for a Task Type The problem with using a formal limited private type is in the need to determine if one of the tasks being monitored has terminated. The 'Terminated attribute only applies to Task objects, either directly, or implicitly through an access to the task object. A limited private type is too general. It is not viewed within the generic as a task type. I know. I tried this first. The only way to make such a system work is to creat a limited record type containing an access to task type. You could then create a function taking a parameter of the record type, returning the proper response from the 'Terminated attribute. Although this is easily done, it is not what I wanted. I had hoped to be able to create a generic package directly usable with most any task type. This appears to be one problem not solvable in Ada, yet easily solved in Java. I would like to add a generic task type formal parameter to the list of improvements for the next version of Ada. Jim Rogers Colorado Springs, Colorado USA Pat Rogers wrote: > > "James Rogers" wrote in message > news:3AA80A68.A2C8B042@worldnet.att.net... > > I have looked through "Ada as a Second Language" and the Ada Reference > > manual. I cannot find any proper form to pass a task type as a > > generic formal parameter. > > > > Is there a generic formal parameter form for this purpose? > > > > I wanted to create a generic package I call Task_Governor. This > > package would control the number of tasks one could create at once. > > The idea is that task resources may be limited. This package would > > allow someone to limit the number of tasks to a maximum specified. > > An instantiation of the package would monitor the tasks it started > > and allow another to be started when one of the tasks terminated. > > > > My problem is that I cannot figure out how to specify a task type > > as a generic formal parameter. > > There is no generic formal task type; you have to use a limited private > formal. > > --- > Patrick Rogers Consulting and Training in: > http://www.classwide.com Real-Time/OO Languages > progers@classwide.com Hard Deadline Schedulability Analysis > (281)648-3165 Software Fault Tolerance _______________________________________________ comp.lang.ada mailing list comp.lang.ada@ada.eu.org http://ada.eu.org/mailman/listinfo/comp.lang.ada