comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Storage management
Date: Fri, 7 Nov 2008 10:20:00 +0100
Date: 2008-11-07T10:20:00+01:00	[thread overview]
Message-ID: <1pqpgcv6v4qxq$.1wkkgkw2yncf.dlg@40tude.net> (raw)
In-Reply-To: 49140215$0$23600$4f793bc4@news.tdc.fi

On Fri, 07 Nov 2008 11:54:05 +0200, Niklas Holsti wrote:

> Dmitry A. Kazakov wrote:
>> I have a general question. Does anybody use abort
>> and asynchronous transfer of control?
> 
> I do, to set a limit on the running time of a possibly lengthy 
> procedure Analyse:
> 
>      select
>         delay Opt.Max_Analysis_Time;
>         Output.Error ("Maximum analysis time exceeded.");
>      then abort
>         Analyse;
>      end select;

That does not look like a good example. In such cases there would be some
GUI with progress indication stuff, etc. I mean that most likely Analyse
would periodically call something in order to indicate its state; store the
results etc. These would be natural candidates to abort it "cooperatively,"
through an exception propagation.

I think that abort/ATC as a language feature just does not hold with Ada's
level of safety. 

>> After all, there is no chance to have them reasonably working anyway.
> 
> It seems to work for me (GNAT 3.15p), except that I had to add a 
> dummy "delay 0.1" at the end of the main subprogram. Otherwise the 
> program would sometimes hang indefinitely in the termination phase. 
> This program has no tasks, so the abort and ATC are the only form 
> of concurrency.

The example I meant was to cancel Get_Line. It worked once in 3.15p under
Windows, if I correctly remember. It does not work now. And there is
absolutely no guaranty that it will ever work.

I honestly believe that the only case that may justify abort/ATC is
cancellation of an outstanding blocking I/O. But exactly this case is not
guaranteed to work, or rather is guaranteed not to work...

>> How about to remove that stuff altogether and make a far more important
>> finalization right and fast?
> 
> Isn't pragma Restrictions (No_Select_Statements) enough? Or is it 
> too strong, and a new restriction specifically for ATC would be better?

I would prefer pragma Cancelable put on a task. If a task is not cancelable
then abort would raise Tasking_Error, and an ATC in the task body would be
a compile-time error. All tasks would be non-cancelable per default.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2008-11-07  9:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-01 11:13 Storage management Florian Weimer
2008-11-01 22:28 ` Robert A Duff
2008-11-02 14:27   ` Florian Weimer
2008-11-07  1:14     ` Randy Brukardt
2008-11-07  8:30       ` Dmitry A. Kazakov
2008-11-07  9:54         ` Niklas Holsti
2008-11-07  9:20           ` Dmitry A. Kazakov [this message]
2008-11-07 12:12             ` Niklas Holsti
2008-11-07 13:22               ` Dmitry A. Kazakov
2008-11-07 13:28                 ` Georg Bauhaus
2008-11-07 14:41                   ` Dmitry A. Kazakov
2008-11-10 14:28                 ` christoph.grein
2008-11-10 16:08                   ` Dmitry A. Kazakov
2008-11-08 11:04         ` sjw
2008-11-08 12:33           ` Dmitry A. Kazakov
2008-11-10  9:34             ` sjw
2008-11-01 22:36 ` sjw
replies disabled

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