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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.182.24.41 with SMTP id r9mr45730772obf.25.1452114854420; Wed, 06 Jan 2016 13:14:14 -0800 (PST) X-Received: by 10.182.231.229 with SMTP id tj5mr307616obc.13.1452114854398; Wed, 06 Jan 2016 13:14:14 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!h5no823168igh.0!news-out.google.com!f6ni45581igq.0!nntp.google.com!o2no515654iga.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 6 Jan 2016 13:14:14 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=149.32.224.36; posting-account=Qh2kiQoAAADpCLlhT_KTYoGO8dU3n4I6 NNTP-Posting-Host: 149.32.224.36 References: <446ae62f-6b95-4a4f-b253-85af071b6bf6@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Abortable Timed Action From: Anh Vo Injection-Date: Wed, 06 Jan 2016 21:14:14 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:29037 Date: 2016-01-06T13:14:14-08:00 List-Id: On Thursday, December 31, 2015 at 10:09:30 AM UTC-8, T.G. wrote: > On 2015-12-31, Anh Vo wrote: > > I think accuracy more important than better/simpler way. There is a > > drifting issue in your codes in term of time since delay statement > > is involved. In addition, timer has no problem of this kind. If you > > decide to use timer, take look at > > http://www.adacore.com/adaanswers/gems/ada-gem-15/. Let me know if > > have any question. > > > > Anh Vo >=20 > Very nice example. I didn't know about Ada.Real_Time.Timing_Events, > I'll probably go with that. Thanks for the pointer. After looking at your original post again, I believe your code should work = after replacing delay statement by delay until statement. The delay until s= tatement does not have time drifting issue. In addition, then Entry Finish = can be replaced by the terminate alternative. The modified version is shown= below. with Ada.Calendar; use type Ada.Calendar.Time; with Ada.Text_Io; use Ada.Text_Io; -- ... -- ... task type Timed_Action_Task is=20 entry Exec_After (T : Duration);=20 entry Cancel;=20 end Timed_Action_Task;=20 task body Timed_Action_Task is=20 Timeout : Duration;=20 begin=20 loop=20 select=20 accept Exec_After (T : Duration) do=20 Timeout :=3D T;=20 end Exec_After;=20 select=20 accept Cancel;=20 or=20 delay until (Ada.Calendar.Clock + Timeout);=20 Put_Line ("Do Something");=20 end select;=20 or=20 terminate; end select;=20 end loop;=20 end Timed_Action_Task;