comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Ada.Real_Time.Time_Last
Date: Fri, 17 Nov 2017 09:20:00 +0000
Date: 2017-11-17T09:20:00+00:00	[thread overview]
Message-ID: <ly8tf5dzy7.fsf@pushface.org> (raw)
In-Reply-To: f73kt9F818aU1@mid.individual.net

Niklas Holsti <niklas.holsti@tidorum.invalid> 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.


  reply	other threads:[~2017-11-17  9:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-15 14:28 Ada.Real_Time.Time_Last Simon Wright
2017-11-15 20:03 ` Ada.Real_Time.Time_Last Niklas Holsti
2017-11-17  9:20   ` Simon Wright [this message]
2017-11-17 21:39     ` Ada.Real_Time.Time_Last Niklas Holsti
2017-11-18 13:06       ` Ada.Real_Time.Time_Last AdaMagica
2017-11-18 13:18         ` Ada.Real_Time.Time_Last Niklas Holsti
2017-11-18 14:00           ` Ada.Real_Time.Time_Last AdaMagica
2017-11-18 14:15           ` Ada.Real_Time.Time_Last Jeffrey R. Carter
2017-11-18 15:24             ` Ada.Real_Time.Time_Last Niklas Holsti
2017-11-18 16:01               ` Ada.Real_Time.Time_Last Dmitry A. Kazakov
2017-11-18 17:31                 ` Ada.Real_Time.Time_Last Niklas Holsti
2017-11-18 22:20               ` Ada.Real_Time.Time_Last Robert A Duff
2017-11-19 10:50                 ` Ada.Real_Time.Time_Last Niklas Holsti
2017-11-20  5:57                 ` Ada.Real_Time.Time_Last J-P. Rosen
2019-01-29 22:03       ` Ada.Real_Time.Time_Last Simon Wright
replies disabled

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