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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a0fe76afdfe9e57d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-11 12:50:33 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: milliseconds and delay until Date: 11 Jun 2003 20:49:49 +0100 Organization: Pushface Sender: simon@smaug Message-ID: References: NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1055361032 16004 62.49.19.209 (11 Jun 2003 19:50:32 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Wed, 11 Jun 2003 19:50:32 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.93 Xref: archiver1.google.com comp.lang.ada:39004 Date: 2003-06-11T20:49:49+01:00 List-Id: Thomas Bruns 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.