comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Eachus <rieachus@comcast.net>
Subject: Re: Strange warning message
Date: Tue, 28 Nov 2017 16:43:58 -0800 (PST)
Date: 2017-11-28T16:43:58-08:00	[thread overview]
Message-ID: <705c80ad-2338-4c81-b2b5-d5ea5e2b5b62@googlegroups.com> (raw)
In-Reply-To: <7c246c12-77f6-45c9-a05a-9afe934df332@googlegroups.com>

On Monday, November 27, 2017 at 3:40:41 AM UTC-5, reinert wrote:
> Hei there,
> 
> when I compile the enclosed program with option "-gnatwa" (i.e. "gnatmake -gnatwa test1k.adb", I get the following annoying warning: 

This is not about the warning, but overthinking the problem.  ALL tasks that declared at the library level are "fire and forget" from the point of view of the main program, and it is the only sane way to get this behavior.  10.2(25) requires that all such tasks complete (or are waiting at a terminate alternative) for the program (partition) as a whole to complete.

Note that it is the parent of the task that matters here, not whether or not it is of a task type.  If you need to fire off tasks, but don't know the number of tasks needed until the main program is running, you will need a task type, and an access type both declared in a library package:

package Workers is
  task type Worker;
  type WA: access Worker;
end Workers;

You can track the existence of Worker tasks or not.  I have a number of programs where the main program figures out how many Workers are needed, spawns them, and sits around waiting so it can print out a timestamp.  It is much easier to put all the Workers inside the main program to do this.  If  you need tasks whose master is the environment task and some global close behavior, that can get messy.  But I've never had the problem.

Um.  I have to explain that.  If you need library level tasks, go right ahead.  Create a task with two entries, basically a counting semaphore.  All the worker tasks call Add in their elaboration code, and Remove just before completing.  Now it the body of that task, you have a place for your last wishes.  Why is this sometimes needed?  If you have a distributed program across hundreds of nodes, you end up with a two or three level tree to create all the per node worker tasks.  The main program may complete hours before the worker tasks, and in fact, before all the worker tasks are created...


  parent reply	other threads:[~2017-11-29  0:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-27  8:40 Strange warning message reinert
2017-11-27  9:00 ` Jacob Sparre Andersen
2017-11-27  9:13   ` reinert
2017-11-27  9:45     ` Jacob Sparre Andersen
2017-11-27 10:43       ` reinert
2017-11-27  9:01 ` gautier_niouzes
2017-11-27  9:09   ` gautier_niouzes
2017-11-27  9:27     ` reinert
2017-11-27 10:42 ` Jeffrey R. Carter
2017-11-27 10:47   ` reinert
2017-11-27 11:52     ` reinert
2017-11-29  0:43 ` Robert Eachus [this message]
2017-11-29 10:39   ` reinert
2017-11-29 20:47     ` Randy Brukardt
2017-11-30 14:11       ` reinert
2017-12-01 22:53     ` Robert Eachus
2017-12-02  8:47       ` Simon Wright
2017-12-02  9:47         ` Niklas Holsti
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox