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.66.222.9 with SMTP id qi9mr19019843pac.28.1405615564643; Thu, 17 Jul 2014 09:46:04 -0700 (PDT) X-Received: by 10.182.1.230 with SMTP id 6mr18781obp.31.1405615564501; Thu, 17 Jul 2014 09:46:04 -0700 (PDT) Path: border1.nntp.dca.giganews.com!nntp.giganews.com!goblin3!goblin.stu.neva.ru!news.ripco.com!news.glorb.com!h18no1705481igc.0!news-out.google.com!bp9ni940igb.0!nntp.google.com!h18no1705477igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 17 Jul 2014 09:46:04 -0700 (PDT) In-Reply-To: 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> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7581b098-ea30-4b34-a51e-2f0dd5a57563@googlegroups.com> Subject: Re: Timeouts in Ada From: NiGHTS Injection-Date: Thu, 17 Jul 2014 16:46:04 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.dca.giganews.com comp.lang.ada:187654 Date: 2014-07-17T09:46:04-07:00 List-Id: On Thursday, July 17, 2014 12:12:13 PM UTC-4, Adam Beneschan wrote: >=20 > I think the mistake you're making is treating the two sequences of statem= ents=20 >=20 >=20 >=20 > Password_Server.Set (User_Name, Password); >=20 > Put_Line ("Done"); >=20 >=20 >=20 > and=20 >=20 >=20 >=20 > delay 10.0; >=20 > Put_Line ("The system is busy now, please try again later."); >=20 >=20 >=20 > as independent "bodies". >=20 >=20 >=20 > That's not how SELECT works. The first statement following SELECT is tre= ated specially. It is restricted; it can only be an entry call, an ACCEPT,= or a DELAY (the DELAY is possible only if there's a "THEN ABORT" part). T= he first statement following OR is also restricted, and is treated speciall= y; if you're selecting on an entry call, it *must* be a DELAY. >=20 >=20 >=20 > So instead of looking at this as two separate blocks of code and trying t= o figure out how the task executes those two blocks, you need to look at th= ose first statements to see what the SELECT's purpose is. And when you hav= e SELECT ... OR DELAY 10.0, it means that the task waits until= the entry is available, but it only waits 10 seconds and then gives up. A= nd then, depending on whether the entry call timed out or not, it executes = one or the other of the statements that *follow* the first statement. This= doesn't require separate threads trying to execute both blocks. =20 >=20 >=20 >=20 > Look at it more like this [this is not real Ada code, of course]: >=20 >=20 >=20 > if Try_Entry_Call (Password_Server.Set (User_Name, Password), Timeout= =3D> 10.0) =3D ACCEPTED then >=20 > Wait_For_Rendezvous_To_Complete; >=20 > Put_Line("Done"); >=20 > else >=20 > Put_Line("The system is busy now, please try again later.");=20 >=20 > end if; >=20 >=20 >=20 > If the first statement after SELECT is an ACCEPT or DELAY, or if there's = a THEN ABORT clause, the statement will have different semantics, and it wo= n't look like the IF statement I wrote above. There are four different kin= ds of SELECT. >=20 >=20 >=20 > -- Adam Your answer was highly intuitive, so thank you for your careful explanation= .=20 So even if the entry call takes an hour, it will still wait the full hour u= ntil it completes before entering the "or delay" section? This is what I am= understanding so far. Also, can two entry calls be placed like this? select call_1(params) ... or call_2(params) ... or delay 10 ... end select If so, how would it know which finishes first without having them run concu= rrently? Don't see a point in having them run one after the other. I have also seen the select used with an "else". What exactly is the differ= ence between "or" and "else"? Is "else" used when a "delay" is not involved= ? Otherwise I don't see the point in the "else" path.