On 2014-04-01, 8:10 PM, Martin Thomson wrote:

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.

Yes, agreed. But I'm claiming this example against the one in my previous email!

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

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

And how do we enforce people to write code like the above example using the current Atomic interface?

Ehsan

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to