[haiku-commits] Re: haiku: hrev50886 - in src: add-ons/media/media-add-ons/multi_audio kits/media/experimental

  • From: Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 20 Jan 2017 21:12:18 +0100

On Fri, Jan 20, 2017 at 9:08 PM, Rene Gollent <anevilyak@xxxxxxxxx> wrote:

On Fri, Jan 20, 2017 at 3:07 PM, Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
wrote:
Why it's more error prone? Keeping the Autolocker alive is not anything
useful either.

Yes it is, for the simple reason that the compiler automatically
ensures that the lock is released when the locker goes out of scope
(since Autolocker's destructor deals with making that call).


The var is out of scope when the MultiAudioNode die.


In your
new code, if someone modifies it in the future in some more
complicated way, one can easily forget an Unlock(), leading to later
hard-to-debug errors. Autolocker doesn't exist just for fun.

Rene


No danger someone will mess with it, it's just a safe lock on startup and
they are three compact lines at the head of the function. The Autolock is
used then in the way you want.


-- 
Saluti,
Dario

« Nullius addictus iurare in verba magistri, quo me cumque rapit tempestas,
deferor hospes. »

Other related posts: