On Wed, Apr 02, 2014 at 05:37:39PM +0200, Honza Bambas wrote: > On 4/2/2014 5:24 PM, Trevor Saunders wrote: > >On Wed, Apr 02, 2014 at 05:03:53PM +0200, 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. > >> > >>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 :) > >> > >>According the refcnt code (or any code that may be concerned) better is to > >>treat is as "always thread safe" if not an overkill of course... Same as > >>you wear condoms with strangers, right? > >so are you offering to audit all of the existing code that might be > >used with Atomic<T> to make sure it is threadsafe? > > Maybe yes, as I want to do for usage of weak reference in bug > https://bugzilla.mozilla.org/show_bug.cgi?id=956338 > > On the other hand, none of the suggestions here doesn't sound to me like > there would be no need for an audit after we migrate to them and be > perfectly safe. Despite we would probably have to change all places we use > atomics right now - which is more or less equal to an audit :)
no, you'd need to audit more than just what currently uses atomics because of things like this template<typename T> T MaxOf3(T& a, T& b, T& c) { T temp = a > b ? a : b; return temp > c ? temp : c; } Which is fine as long as we only use it with non threadsafe objects, but if someone comes along and uses it on atomic values they'll expect the implementation is threadsafe and so introduce a race. Trev > -hb- > > > > >Trev > > > >>-hb- > >> > > > > > >>_______________________________________________ > >>dev-platform mailing list > >>dev-platform@lists.mozilla.org > >>https://lists.mozilla.org/listinfo/dev-platform > > > > > >_______________________________________________ > >dev-platform mailing list > >dev-platform@lists.mozilla.org > >https://lists.mozilla.org/listinfo/dev-platform > > _______________________________________________ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform
signature.asc
Description: Digital signature
_______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform