[interfacekit] Re: locking...

On Thu, 19 Jun 2003, Adi Oanca wrote:

> Question:
>
> My BView::Origin is defined like this:
>
> BPoint BView::Origin(void) const {
>  if (owner){
>   owner->AssertLocked();
>  }
>  return fBounds.LeftTop();
> }
>
>
> Be's like:
>
> BView::Origin(void) const {
>  BLooper::check_lock(void)
>  _BSession_::swrite_l(long)
>  _BSession_::swrite_l(long)
>  _BSession_::swrite_l(long)
>  BWindow::Flush(void) const
>  _BSession_::sread(long, void *)
> }
>
> In Be's implementation, it is clear that a lock is required.
> In my method, is it required?

Yes. Besides the fact, that neither SetOrigin(), nor Origin() access the
variable in an atomic way, locking also ensures that the object won't be
deleted while being accessed.

CU, Ingo

Other related posts: