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,28c043d47104f5d9 X-Google-Attributes: gid103376,public From: Tucker Taft Subject: Re: Controlled types for resource locking Date: 1999/09/09 Message-ID: <37D7E247.9B3C9FC0@averstar.com>#1/1 X-Deja-AN: 523012457 Content-Transfer-Encoding: 7bit Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.burl.averstar.com References: <936824686.950.0.nnrp-07.c2de848f@news.demon.co.uk> <7r8i8q$fpg$1@nnrp1.deja.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: AverStar (formerly Intermetrics) Burlington, MA USA Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-09-09T00:00:00+00:00 List-Id: Ted Dennison wrote: > > In article , > tmoran@bix.com wrote: > > >I have some code in which I'm protecting a hardware resource using a > > >protected type. It's getting quite a mess at the moment with > lock/unlocks > > >all over the place - especially where exception handlers get > involved. I'm > > You can make a controlled type whose Initialize grabs the lock and > > whose Finalize releases it, then declare an object of this controlled > > type as the first thing in any subprogram (or block) that needs access > > to the hardware. Thus you can't execute code inside the subprogram > > Interesting. In effect you are creating an object just for its side > effects. But if that's all you ever do with the object, wouldn't it be > in danger of being optimized away by the compiler? Or are compilers not > allowed to do that with controlled objects? Limited controlled objects may not be optimized away. There is an AI being debated that would formalize this further, and probably disallow optimizing away non-limited controlled objects when there is a user-defined Initialize procedure. > > -- > T.E.D. > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't. -- -Tucker Taft stt@averstar.com http://www.averstar.com/~stt/ Technical Director, Distributed IT Solutions (www.averstar.com/tools) AverStar (formerly Intermetrics, Inc.) Burlington, MA USA