comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@bix.com
Subject: Re: Controlled types for resource locking
Date: 1999/09/08
Date: 1999-09-08T00:00:00+00:00	[thread overview]
Message-ID: <iMAB3.157$QV.27052@typhoon-sf.pbi.net> (raw)
In-Reply-To: 936824686.950.0.nnrp-07.c2de848f@news.demon.co.uk

>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
till the Initialize has been called, and you own the resource.  Any way
you leave the subprogram, you are guaranteed the Finalize will release
the resource.
  p.s.  There was a bug in a compiler I used a year or so ago, and
which I believe has since been fixed, such that Finalize would be
called even if Initialize had failed (raised a Cant_Get_Resource
exception, for instance).  Make sure nothing like that is happening
with your system.




  reply	other threads:[~1999-09-08  0:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-08  0:00 Controlled types for resource locking Steve Folly
1999-09-08  0:00 ` tmoran [this message]
1999-09-09  0:00   ` Pat Rogers
1999-09-09  0:00     ` Matthew Heaney
1999-09-09  0:00       ` Pat Rogers
1999-09-09  0:00         ` Matthew Heaney
1999-09-09  0:00           ` Pat Rogers
1999-09-09  0:00   ` Ted Dennison
1999-09-09  0:00     ` Tucker Taft
1999-09-08  0:00 ` Matthew Heaney
1999-09-08  0:00 ` David C. Hoos, Sr.
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox