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.4 required=5.0 tests=BAYES_00,SUBJ_ALL_CAPS autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,51359402da60c472 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-17 23:11:34 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!wn12feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!rwcrnsc51.ops.asp.att.net.POSTED!not-for-mail Message-ID: <3EF0026E.2050309@attbi.com> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: DYNAMIC ADA TASK CREATION? References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.62.164.137 X-Complaints-To: abuse@attbi.com X-Trace: rwcrnsc51.ops.asp.att.net 1055916690 24.62.164.137 (Wed, 18 Jun 2003 06:11:30 GMT) NNTP-Posting-Date: Wed, 18 Jun 2003 06:11:30 GMT Organization: AT&T Broadband Date: Wed, 18 Jun 2003 06:11:30 GMT Xref: archiver1.google.com comp.lang.ada:39374 Date: 2003-06-18T06:11:30+00:00 List-Id: Simon Wright wrote: >> How to create dynamic for example N tasks. I don't know how create N of >>tasks and array (not list). For example user interface gets an Integer (N) >>from user and then we create N number of Task in ADA. How to do this?Can >>anybody help me? > > > (uncompiled) > > task type t is > -- some entries > end t; > > task body t is > begin > -- code > end t; > > type ts is array (positive range <>) of t; > > n : positive; > > begin > > -- read in n > > declare > the_ts : ts (1 .. n); > begin > -- do something with the tasks > -- NB, can't pass this point until all the tasks have terminated > end; Correct. But if you don't want to get stuck there, do this instead: -- task type t as above type ta is access t; type ts is array (positive range <>) of ta := new t; n : positive; begin -- read in n declare the_ts : ts (1 .. n); begin -- do something with the tasks -- NB, CAN pass this once all the tasks have been created. end; For an ordinary task object, the creator of the object is the master (in the original example, a declare block. But for a task created by an allocator, the place where the access type was declared determines who is the master. (In either case, if that is in a library package, the master is the environment task.)