From: Simon Wright <simon@pushface.org>
Subject: Re: milliseconds and delay until
Date: 11 Jun 2003 20:49:49 +0100
Date: 2003-06-11T20:49:49+01:00 [thread overview]
Message-ID: <x7vu1aw4co2.fsf@pushface.org> (raw)
In-Reply-To: bc7smt$357$04$1@news.t-online.com
Thomas Bruns <newsgroup@donbruno.de> writes:
> how can I handle the until delay statement, too do this: ????
>
>
> with ADA.Calendar; use ADA.Calendar;
>
> procedure ....
>
> MS : INTEGER; --milliseconds
>
> begin
> MS:= INTEGER(FLOAT(seconds(clock)) * 1000);
>
> MS := MS + 100;
>
> delay until MS; ---???? it is wrong :-( it must be a time type :-( but I
> -- need the clock from a fixed time and add some milliseconds...
> --and then the until delay statement....How can I handle this???
>
> end;
with Ada.Calendar;
with Ada.Text_IO;
procedure Delaying is
Start : constant Ada.Calendar.Time := Ada.Calendar.Clock;
Next : Ada.Calendar.Time := Start;
Millisec : constant Duration := 0.001;
use type Ada.Calendar.Time;
begin
for I in 1 .. 5_000 loop
Next := Next + Millisec;
delay until Next;
end loop;
Ada.Text_IO.Put_Line (".. that took"
& Duration'Image (Ada.Calendar.Clock - Start));
end Delaying;
The output here (Mandrake 9.1, GNAT 3.16a) is
.. that took 5.011935000
NB!! on most desktop machines you'll get a minimum actual delay of 10
ms (a tick) or even 2 ticks; what happens, I think, is that many of
the "delay until"s turn out to be delaying until a time that has
already passed, so the program spins until it catches up.
next prev parent reply other threads:[~2003-06-11 19:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-11 18:31 milliseconds and delay until Thomas Bruns
2003-06-11 18:46 ` Jano
2003-06-11 18:58 ` Thomas Bruns
2003-06-11 19:29 ` Jano
2003-06-11 19:49 ` Simon Wright [this message]
2003-06-11 20:29 ` tmoran
2003-06-12 6:20 ` Dmitry A. Kazakov
2003-06-11 19:59 ` Frank J. Lhota
2003-06-12 3:06 ` Steve
2003-06-12 20:26 ` Simon Wright
2003-06-12 21:41 ` Martin Dowie
2003-06-14 6:04 ` 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