[RFC] Reference counting on Audio objects for /dev/dsp
Thu Jul 15 20:28:00 GMT 2004
On Thu, 15 Jul 2004, Christopher Faylor wrote:
> On Thu, Jul 15, 2004 at 02:57:17PM -0400, Igor Pechtchanski wrote:
> >> 2) The other problem is that I find it sort of odd to see the dec()
> >> method performing a deletion. Couldn't this be handled where, IMO,
> >> it should logically be handled, in the close function, e.g.,
> >> if (!audio_out_->dec ())
> >> delete audio_out_;
> >> ?
> >Umm, that's actually a rather standard construct in reference counting
> >(called "object suicide" -- you should get some references if you Google
> >for "object suicide reference counting").
> Yes, I thought that would be your answer, however, I don't like the idea
> of having a method called "inc" which just increments a count and a method
> called "dec" which decrements a count and, oh, hey, it might delete the
> object, too.
> It seems more straightforward to delete audio_out_ in the place where
> you'd expect it to be deleted rather than having a "dec" call which,
> if you check, you'll notice that it deletes the buffer.
> Or, as a compromise, don't call it 'dec'. Call it something which
> illustrates what it is doing.
Right. I think the compromise is good -- I was thinking of maybe using
registerReference() and releaseReference() (or deregister?). We could
shorten them by removing "Reference" from the names, too. In any case,
I'd wait for Gerd's input before deciding on the specific code to go in.
|\ _,,,---,,_ firstname.lastname@example.org
ZZZzz /,`.-'`' -. ;-;;,_ email@example.com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster." -- Patrick Naughton
More information about the Cygwin-patches