[interfacekit] Re: Fwd: BAutolock

Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx> wrote:
> On 2003-09-11 at 07:24:38 [+0200], Waldemar Kornewald wrote:
[...]
> > The constructor will get an additional parameter:
> > bool initialLockStatus = false
> > With this parameter you can specify if the supplied BLocker/BLooper 
> > is
> > already locked and thus does not need additional locking.
> > All constructors will call Relock().
> > 
> > bool Relock()
> > This locks the BLocker/BLooper object if it is not already locked 
> > by this
> > object. This method is called by the constructor(s).

I think the name of this method is misleading, it should just be Lock() 
IMO.

> > void Unlock()
> > This allows to unlock the locker before the destructor is called 
> > (the
> > BLocker's/BLooper's Unlock() function will only be called if the 
> > internal
> > status says it is locked). This method is called by the destructor.

That one method I like.

> > void SetLockStatus(bool lockStatus)
> > This allows to set the internal lock status in order to prevent 
> > Unlock()'ing
> > the BLocker/BLooper by Unlock() (or force an Unlock()).

But this one is pretty much useless in my opinion.
I would rather have Set() and Unset() pairs (I am frequently using a 
method Keep() in similar things, though).
Set() could have a parameter that specifies if the BLocker is already 
locked or not, Unset() would not unlock it on destruction. That would 
allow it to use in almost all locking cases.

Adios...
   Axel.


Other related posts: