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, MSGID_RANDY 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: Ted Dennison Subject: Re: Controlled types for resource locking Date: 1999/09/09 Message-ID: <7r8i8q$fpg$1@nnrp1.deja.com>#1/1 X-Deja-AN: 522955185 References: <936824686.950.0.nnrp-07.c2de848f@news.demon.co.uk> X-Http-Proxy: 1.0 x29.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Thu Sep 09 15:04:03 1999 GMT X-MyDeja-Info: XMYDJUIDtedennison Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.6 [en] (WinNT; I) Date: 1999-09-09T00:00:00+00:00 List-Id: 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? -- T.E.D. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.