comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adambeneschan@gmail.com>
Subject: Re: Timeouts in Ada
Date: Thu, 17 Jul 2014 11:12:20 -0700 (PDT)
Date: 2014-07-17T11:12:20-07:00	[thread overview]
Message-ID: <8e1281ee-79b4-4878-91db-6d0a65c96013@googlegroups.com> (raw)
In-Reply-To: <7581b098-ea30-4b34-a51e-2f0dd5a57563@googlegroups.com>

On Thursday, July 17, 2014 9:46:04 AM UTC-7, NiGHTS wrote:

> Your answer was highly intuitive, so thank you for your careful explanation. 

Glad it helped. 
> 
> So even if the entry call takes an hour, it will still wait the full hour until it completes before entering the "or delay" section? This is what I am understanding so far.

If the entry is *selected* right away, but the rendezvous takes an hour (i.e. the body of the ACCEPT statement just sits there), then yes, the code will wait.  Normally, a rendezvous that could wait an hour shouldn't be written.  I think the idea is that rendezvous should be completed fairly quickly.

> Also, can two entry calls be placed like this? 
> 
>     select call_1(params)
>         ...
>     or call_2(params)
>         ...
>     or delay 10
>         ...
>     end select

No.  See my comments below.

> If so, how would it know which finishes first without having them run concurrently? Don't see a point in having them run one after the other.

If this statement *were* implemented, it would choose whichever entry call became *available* first.  Then when one of them, say call_2, became available, it would cancel all the other entry calls, wait for the call_2 rendezvous to complete, and execute the sequence of statements after the call_2.  In theory, this shouldn't need anything to "run concurrently".  The current task would go into a wait state, and the tasking implementation would have a list of entries the task was waiting for, and the implementation would wake it up as soon as one of those entries could be selected.

In practice, however, apparently it's too complicated to implement.  I don't know the details.  It may be that it's too hard to implement when combinations of features are used.  In any case, the language designers considered adding this ability (SELECT on multiple entries), but decided against it.

 
> I have also seen the select used with an "else". What exactly is the difference between "or" and "else"? Is "else" used when a "delay" is not involved? Otherwise I don't see the point in the "else" path.

ELSE is pretty much the same as OR DELAY 0.0;.  It selects the entry if it happens to be available right away (in which case it waits for the rendezvous to complete, then executes any other statements after the entry call).  Otherwise it gives up immediately and jumps right to the sequence of statements after the ELSE.  Note that, unlike OR, the first statement after ELSE is not special and can be any Ada statement.

                                  -- Adam


  parent reply	other threads:[~2014-07-17 18:12 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
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 [this message]
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