On 2014-04-02, 11:03 AM, Honza Bambas wrote:
On 4/2/2014 11:33 AM, Nicolas B. Pierron wrote:
--lock(mRefCnt);
if (lock(mRefCnt) == 0) {
delete this;
}
This way, this is more obvious that we might not be doing the right
things, as long as we are careful to refuse AtomicHandler references
in reviews.
I personally don't think this will save us. This can easily slip
through review as well.
Hmm... This is kind of an interesting suggestion. I think it would be
better to call it AtomicLock or something along those lines. But, at
that point, what is the goal exactly? Is
--AtomicLock(mRefCnt)
much more readable than:
AtomicFetchAndSub(&mRefCnt, -1);
It is at least weird in that it's decrementing a temporary which is
usually a bad idea. And I think we have already lost on the ease of use
front here.
Also, I'm using our mozilla::Atomic<> for not just refcounting but as an
easy lock-less t-s counters. If I had to change the code from
mMyCounter += something; to mozilla::Unused <<
AtomicFetchAndAdd(&mMyCounter, something); I would not be happy :)
To be clear, I also like convenience where it doesn't trade off safety,
but this is not one of those cases. Also, code is read more often than
it's written, etc. :-)
Cheers,
Ehsan
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform