comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Eachus <rieachus@comcast.net>
Subject: Re: How to tell whether program finalization can be suppressed
Date: Fri, 1 Dec 2017 19:08:57 -0800 (PST)
Date: 2017-12-01T19:08:57-08:00	[thread overview]
Message-ID: <09af341f-059f-47c9-809d-14eda9da2352@googlegroups.com> (raw)
In-Reply-To: <lyzi729lh2.fsf@pushface.org>

On Friday, December 1, 2017 at 4:39:24 PM UTC-5, Simon Wright wrote:
 
> I need to find a way of determining whether the RTS actually needs
> program-level finalization (that is, finalization called on program
> exit), because that's where the bad code is generated.
> 
> Clearly, if the program never exits, there will be no need for
> program-level finalization.
> 
> Amongst other things, I can test for specific restrictions, and I'm
> wondering whether No_Task_Termination would be appropriate for this?
> (I'm assuming that the environment task mustn't terminate, even if the
> main program exits; and in this RTS, exceptions can't be propagated).

I have some programs where all the work is done in worker tasks, and the main program just needs to stay around until they all finish.  What I always seem to end up with, because I need some way of determining that the program is finished is something like this:

procedure Main is
begin
  --get a timestamp, and print out that the program is running.
  --fire off lots of library-level tasks, don't want them to depend on
  --the main program.
  declare
    task Monitor is
      entry Killer;
    end Monitor;
 
    task body Monitor is
    begin
      select
        accept Killer;
      or
        terminate;
      end select;
    end Monitor;
  end;
  -- print a timestamp...
end Main;

The worker tasks don't include terminate alternatives, they only call Killer in extreme error cases like can't open data file, network errors, etc.  When the last library level task goes away, the terminate alternative is selected.

Sounds like this sort of structure would avoid your bug.


  parent reply	other threads:[~2017-12-02  3:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-01 21:39 How to tell whether program finalization can be suppressed Simon Wright
2017-12-01 22:43 ` Randy Brukardt
2017-12-02  9:48   ` Simon Wright
2017-12-04 20:18     ` Randy Brukardt
2017-12-04 22:41     ` Simon Wright
2017-12-02 11:12   ` AdaMagica
2017-12-03 17:16     ` Robert Eachus
2017-12-04 11:58       ` AdaMagica
2017-12-04 14:36         ` Robert Eachus
2017-12-04 17:16           ` AdaMagica
2017-12-04 18:21             ` Jeffrey R. Carter
2017-12-04 20:25             ` Randy Brukardt
2017-12-04 20:22         ` Randy Brukardt
2017-12-02  3:08 ` Robert Eachus [this message]
2017-12-27 15:49 ` Simon Wright
replies disabled

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