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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: dynamically create tasks Date: Sat, 11 Oct 2014 08:53:31 +0300 Organization: Tidorum Ltd Message-ID: References: <47e42c27-69ba-44fc-861f-c230f5ac04f4@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net eoQgoTUKJZYtCxRqLWl5OgvqVvaJlOd67ah02LKPb/noZgRJ6k Cancel-Lock: sha1:jhRAqa45E9gQFj3z1ES+teHZBJ8= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <47e42c27-69ba-44fc-861f-c230f5ac04f4@googlegroups.com> Xref: news.eternal-september.org comp.lang.ada:22339 Date: 2014-10-11T08:53:31+03:00 List-Id: On 14-10-11 04:49 , compguy45@gmail.com wrote: > If you have one task body and would like to create 5 of these > tasks since there is one task body there will only be one task > created plus main task....how would you create 20 tasks with same body? > is there way to do this? > Use task types. Instead of saying task My_Own_Task is ... end My_Own_Task; say task type My_Own_Task is ... end My_Own_Task; The "task body" part stays the same. Then you can create as many tasks as you like, of this type, using what looks like a normal variable declaration: Thinker, Doer, Builder, Painter : My_Own_Task; and now all these tasks are running. You can also create arrays of tasks in the normal way, " ... array ( ... ) of My_Own_Task", you can have access types for tasks and use "new My_Own_Task", and so on. (However, I would suffix task-type names with "_T", just as I do for other types, so I would write My_Own_Task_T for the task-type name.) Note that when you use a task type and have several tasks with the same body, there must be some way for each task to know what *it* should do; all tasks should of course not do exactly the same thing. One way is to add an entry to each task and call these entries to give different parameters to each task; another way is for each task to call some central task or protected object to get their different parameters. You can also give the task type discriminants that tell each task what to do; that may be useful if you create tasks dynamically (wth "new"). -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .