[interfacekit] Re: Fwd: BAutolock

This is a forward from Waldemar - Erik, could you please open up this 
list? :-)

> 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.

Okay. I hope that the devs do not think a second Lock() will lock the
BLocker twice.

> > > 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.

First of all: what does Keep() do?

I think SetLockStatus() does the same as your Set().
Set(true) is equivalent to SetLockStatus(true), but I prefer my naming. 
:)
Why do we need Unset()? Set(false) (or SetLockStatus(false)) already 
says
that it does not need to be unlocked, does it?
Could you please explain to me the difference between Set(false) and
Unset()?
Would Unset() only affect the destructor while Set(false) also affects
Unlock()? Does this not add too much complexity to a simple class?

What about replacing it with a more general template? On the other 
hand, who
says Lock() returns status_t (or bool) in all classes? Your own 
Benaphore
class might return another value.

Waldemar




Other related posts: