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 X-Received: by 10.224.46.3 with SMTP id h3mr10170619qaf.1.1405587609358; Thu, 17 Jul 2014 02:00:09 -0700 (PDT) X-Received: by 10.182.176.37 with SMTP id cf5mr7046obc.22.1405587594143; Thu, 17 Jul 2014 01:59:54 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newspeer1.nac.net!border2.nntp.dca1.giganews.com!nntp.giganews.com!v10no1116995qac.1!news-out.google.com!bp9ni939igb.0!nntp.google.com!h18no2975740igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 17 Jul 2014 01:59:53 -0700 (PDT) In-Reply-To: <19saet0lg87pr.yqkkaxl011gq.dlg@40tude.net> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=73.179.102.101; posting-account=wEPvUgoAAABrLeiz_LRhQ3jeEhyfWVMH NNTP-Posting-Host: 73.179.102.101 References: <50bdb713-7ce1-411b-810b-9bdee1d26b7a@googlegroups.com> <19saet0lg87pr.yqkkaxl011gq.dlg@40tude.net> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8a8353c8-3a8e-4b42-9c94-6d6d095faf1d@googlegroups.com> Subject: Re: Timeouts in Ada From: NiGHTS Injection-Date: Thu, 17 Jul 2014 09:00:09 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:20993 Date: 2014-07-17T01:59:53-07:00 List-Id: 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?