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-Thread: a07f3367d7,a4db0fc323f0b09e X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!news.stack.nl!aioe.org!nospam From: "John B. Matthews" Newsgroups: comp.lang.ada Subject: Re: Barrier re-evaluation issue with GNAT 4.3.2 Date: Wed, 30 Sep 2009 11:59:09 -0400 Organization: The Wasteland Message-ID: References: NNTP-Posting-Host: LQJtZWzu+iKlBROuDg+IUg.user.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.0 Cancel-Lock: sha1:8MXsC3TgSGU/tdjKXgnvUr35+KY= User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Xref: g2news2.google.com comp.lang.ada:8543 Date: 2009-09-30T11:59:09-04:00 List-Id: In article , Reto Buerki wrote: > John B. Matthews wrote: > > Using Pragma Detect_Blocking, as suggested by Bob Duff, will tell > > you if the compiler's warning is actualized at run-time. As this is > > a work-around and your original code seems correct, you might > > arrange things so that the original can be restored easily upon > > upgrade or port. > > The code runs correctly even though Program_Error is raised when > compiled with the Detect_Blocking pragma. > > I think it's good enough as a workaround, we will upgrade to GNAT > 4.4.x as soon as possible. Excellent, although upgrading has it's own perils. :-) Another alternative, suggested by Dmitry A. Kazakov, is to replace entry Wait with procedure Wait, which obviates the need for Signal: with Ada.Text_IO; with Alarm_Clock; procedure Main is My_Alarm : Alarm_Clock.Alarm_Type; begin Ada.Text_IO.Put_Line ("Setting alarm ..."); My_Alarm.Set; Ada.Text_IO.Put_Line ("Waiting for alarm ..."); My_Alarm.Wait; Ada.Text_IO.Put_Line ("ALARM!!"); end Main; with Ada.Real_Time.Timing_Events; package Alarm_Clock is protected type Alarm_Type is procedure Set; procedure Wait; end Alarm_Type; end Alarm_Clock; package body Alarm_Clock is use Ada.Real_Time; Timer : Timing_Events.Timing_Event; Fired : Boolean := False; protected body Alarm_Type is procedure Wakeup(Event : in out Timing_Events.Timing_Event) is begin Fired := True; end Wakeup; procedure Set is begin Timer.Set_Handler(In_Time => Seconds (2), Handler => Wakeup'Access); end Set; procedure Wait is begin loop exit when Fired; end loop; end Wait; end Alarm_Type; end Alarm_Clock; > Thanks for all your help! I enjoyed the opportunity to examine this interesting question. -- John B. Matthews trashgod at gmail dot com