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 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Ada.Real_Time.Time_Last Date: Fri, 17 Nov 2017 09:20:00 +0000 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="2020667954af1f8e30c93d9629a52a30"; logging-data="19734"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18dXOAezhgSR1fx9qtzVvpXhqbmzlrIwlY=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (darwin) Cancel-Lock: sha1:CAUtdvBa7hMHOcow8AIKysX/zb8= sha1:3S8IIL0Cexg4Nxvn/DzSEzrgzYE= Xref: feeder.eternal-september.org comp.lang.ada:48960 Date: 2017-11-17T09:20:00+00:00 List-Id: Niklas Holsti writes: > On 17-11-15 16:28 , Simon Wright wrote: >> The only use case I can see for this is to allow us to write >> >> delay until Ada.Real_Time.Time_Last; >> >> at the end of our (Ravenscar) main program. Any other offers? > > Suppose your program has to consider, say, three possible future > events, at the future times A, B, C : Ada.Real_Time.Time, and must > delay until the first of those events happens, so you compute a > variable Next_Event : Ada.Real_Time.Time as the minimum of A, B, and > C, and then do "delay until Next_Time". > > However, if some or all of the events A, B, C might never happen, the > value Time_Last is a useful placeholder to indicate "this event will > never happen", because Time_Last is a "neutral element" for the > operation "minimum of two Time values": minimum (X, Time_Last) = X for > any Time X. > > Many algorithms working with ordered types need a minimal and a > maximal value of the type, for such uses. I found that I'd used Time_First to act as a flag (in my implementation of Timing_Events). Logically I suppose it should be Time_Last. > (By the way, my Ravenscar programs always end in an eternal loop, > never in a delay until Time_Last.) Like loop null; end loop; ? I'd have thought this would prevent the RTS from putting the processor to sleep, thus wasting energy. I used to write loop delay until Clock + Seconds (2); end loop; (which also wastes a little energy) before realizing that (since Time isn't to be relied on after Time_Last) I might as well delay until Time_Last. > (By the further way, it is a pity that Ada does not let Ada.Real_Time > provide the attribute functions Time'Min and Time'Max.) I suppose there'd have to be a way of indicating that a private type was scalar.