On 2014-04-01, at 16:48, Ehsan Akhgari <ehsan.akhg...@gmail.com> wrote:

> My contention is that it is obvious enough by looking at (a) to tell that 
> mRefCnt is an atomic value which should be handled with the necessary care, 
> so the pattern (b) would be caught either at code writing time or at code 
> review time.

My point was that:

--mRefCnt;
if (mRefCnt == 0) {
  delete this;
}

is as much an obvious threading issue as:

if (--mRefCnt == 0) {
  delete this;
}

…absent some extra knowledge.

More verbosity isn’t going to change this.  This might:

count_type tmp = --mRefCnt;
if (tmp == 0) {
  delete this;
}
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to