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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7f1e0b399cd01cb0,start X-Google-Attributes: gid103376,public From: Simon Wright Subject: Unreferenced lock variables Date: 1999/04/11 Message-ID: #1/1 X-Deja-AN: 465201279 X-NNTP-Posting-Host: pogner.demon.co.uk:158.152.70.98 X-Trace: news.demon.co.uk 923859913 nnrp-13:25709 NO-IDENT pogner.demon.co.uk:158.152.70.98 Organization: At Home Newsgroups: comp.lang.ada X-Complaints-To: abuse@demon.net Date: 1999-04-11T00:00:00+00:00 List-Id: I've been looking at using a 'control by allocation' technique (I'm sure there's a more standard name, but I can't find it at the moment: a resource is encapsulated in a type such that declaring an object of the type allocates the resource). For example, procedure Mark (R : in out Synchronized_Unbounded_Ring) is Lock : BC.Support.Synchronization.Write_Lock (R.The_Monitor); begin Mark (Unbounded_Ring (R)); end Mark; where the initialization of Lock calls the appropriate operations on R.The_Monitor (which is a class-wide access ..) to ensure exclusion, in this case for a Writer. Now, GNAT quite properly warns me that Lock is unused; so, having been bitten this way once, I cast around and found that inserting pragma Volatile (Lock); will eliminate the warning. However, it doesn't seem to be as legitimate a use as in the recent thread on Handling Addressing Errors; is there a better way? pragma Import (Ada, Lock) perhaps? or should I look for a different style?