comp.lang.ada
 help / color / mirror / Atom feed
From: NiGHTS <nights@unku.us>
Subject: Re: Timeouts in Ada
Date: Thu, 17 Jul 2014 01:59:53 -0700 (PDT)
Date: 2014-07-17T01:59:53-07:00	[thread overview]
Message-ID: <8a8353c8-3a8e-4b42-9c94-6d6d095faf1d@googlegroups.com> (raw)
In-Reply-To: <19saet0lg87pr.yqkkaxl011gq.dlg@40tude.net>

On Thursday, July 17, 2014 3:42:21 AM UTC-4, Dmitry A. Kazakov wrote:
> 
> This is a timed entry call. The callee must be a task's or a protected
> 
> object's entry.
> 

Are you suggesting that the select/or would not work inside the main procedure? I haven't tried this yet so I don't know yet if this is valid or not.


> 
> Never use them unless you know what you are doing. The language defines the
> 
> way and what can be aborted. This does not work how you would expect it in
> 
> most cases. And it certainly does not work in the cases you liked to use
> 
> it, e.g. for aborting pending blocking I/O. Ada has no way to do this. The
> 
> only things you could safely abort are like some lengthy calculations.
> 

I would never use something I don't understand. This is precisely why I asked this kind of question.


Say I had a subroutine which submits a query to a database in a non-blocking way. Thus it is a loop which waits for a response from the database. Say the caller of this subroutine wants to have a timeout condition attached to this request.

To me the obvious C-style solution here is to pass the timeout value to the procedure and have it check its elapsed time as part of the loop, then break if it takes too long with an exception or a return value stating that a timeout occurred.

My question is this: Is there a more elegant way to do this timeout checking in Ada, perhaps using this select/or system? Or is the C-style technique as elegant as it gets for this kind of problem?

  reply	other threads:[~2014-07-17  8:59 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-17  5:18 Timeouts in Ada NiGHTS
2014-07-17  7:08 ` Simon Wright
2014-07-17  8:35   ` NiGHTS
2014-07-21 23:34   ` Randy Brukardt
2014-07-22  1:11     ` Shark8
2014-07-22  7:39       ` J-P. Rosen
2014-07-22  8:31         ` Simon Wright
2014-07-22 21:52       ` Randy Brukardt
2014-07-17  7:38 ` J-P. Rosen
2014-07-17  8:40   ` NiGHTS
2014-07-17 10:00     ` J-P. Rosen
2014-07-17 19:27   ` Jeffrey Carter
2014-07-17 19:51     ` J-P. Rosen
2014-07-17 20:52       ` Jeffrey Carter
2014-07-17 20:29     ` Adam Beneschan
2014-07-17 20:52       ` J-P. Rosen
2014-07-21 23:44         ` Randy Brukardt
2014-07-17 20:43     ` Jeffrey Carter
2014-07-21 23:37   ` Randy Brukardt
2014-07-17  7:42 ` Dmitry A. Kazakov
2014-07-17  8:59   ` NiGHTS [this message]
2014-07-17  9:48     ` Dmitry A. Kazakov
2014-07-17 17:10       ` NiGHTS
2014-07-17 20:45         ` Dmitry A. Kazakov
2014-07-17 16:12 ` Adam Beneschan
2014-07-17 16:46   ` NiGHTS
2014-07-17 17:11     ` Simon Wright
2014-07-17 17:58       ` NiGHTS
2014-07-17 19:02         ` Jeffrey Carter
2014-07-17 18:58       ` Jeffrey Carter
2014-07-17 18:12     ` Adam Beneschan
2014-07-17 19:27       ` Jeffrey Carter
2014-07-17 18:56     ` Jeffrey Carter
2014-07-23 22:37     ` Robert A Duff
2014-07-24  9:23       ` AdaMagica
2014-07-24 15:37         ` Robert A Duff
2014-07-25  5:16           ` Randy Brukardt
2014-07-25  9:11           ` AdaMagica
2014-07-25 16:15             ` Brad Moore
2014-07-25 16:34             ` Dmitry A. Kazakov
2014-07-17 19:27 ` Jeffrey Carter
replies disabled

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