On Tuesday 15 April 2014 08:02:56 Thiago Macieira wrote: > Em ter 15 abr 2014, às 09:49:53, Matthew Woehlke escreveu: > > If you add the rule that callbacks can't be removed once registered, you > > could do an atomic exchange of the old callback for the new, and require > > that any attached callback calls the previously-registered callback > > also. (This would cost a compare per callback though in case the old is > > null.) This takes a small amount of cleverness at the call site to > > ensure that the pointer to old is written at the same time as the new > > callback is registered, but should be doable. (Depending on available > > intrinsics, you might need to do a CAS loop to first set your old, then > > register your own callback if no one else has done so in the mean time. > > Retry as needed. Under the circumstances, it's pretty unlikely you'd > > ever get stuck in an infinite loop doing this.) > > In other words: use QBasicAtomicPointer.
As mentioned on https://codereview.qt-project.org/#change,83272 Kevin Funk measured the difference between the current approach and using atomics using Olivier's initial benchmark, it's about 4-5x slower for checking if there's a callback set. Since this is affecting every Qt application on a not uncommon hot path, I'd rather trade in theoretical tool stability for general performance. regards, Volker -- Volker Krause | volker.kra...@kdab.com | Senior Software Engineer KDAB (Deutschland) GmbH&Co KG, a KDAB Group company Tel. Germany +49-30-521325470, Sweden (HQ) +46-563-540090 KDAB - Qt Experts - Platform-independent software solutions
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development