On 2003-09-11 at 00:34:33 [+0200], DarkWyrm wrote:
> >
> > since the list doesn't seem to be open for general subscription yet,
> > I
> > forward a request of Waldemar Kornewald's regarding the addition of a
> > BAutolock::Unlock() method. It would be implemented inline and hence
> > not
> > even render apps using it R5 binary incompatible.
> >
> > Opinions?
> I'm inclined to go with your ObjectLocker.h suggestion. It just seems
> to me like AutoLockers should also be AutoUnlockers without the Unlock
> method. I guess that's what BLockers are for. My $0.02. :^)
Oh, don't misunderstand that -- the normal BAutolock semantics wouldn't
change at all. Unlock() would be an additional feature to allow unlocking
before the object is destroyed. It may be helpful e.g. in a case like this:
{
BAutolock autolocker(lockable);
...
if (special error condition) {
autolocker.Unlock();
// do cleanup that requires lockable to be unlocked
...
return error;
}
...
}
return B_OK;
That would otherwise need to be written e.g. like that:
{
BAutolock autolocker(lockable);
...
if (special error condition)
goto err;
...
}
return B_OK;
err:
// do cleanup that requires lockable to be unlocked
...
return error;
Given that I don't think that `goto's are an acceptable construct for
structured programming, I don't need to say that I prefer the first
version. :-P
CU, Ingo