[Development] qt_add/removeObject hooks
Matthew Woehlke
mw_triad at users.sourceforge.net
Wed Apr 16 18:55:38 CEST 2014
On 2014-04-16 03:18, Volker Krause wrote:
> On Tuesday 15 April 2014 08:02:56 Thiago Macieira wrote:
>> 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.
How are you doing that check?
I believe the 'correct' way is 'if (callback)', which calls an inline
operator that accesses the internal pointer directly, i.e.
'callback->operator T*' -> 'callback->_q_value' (which should further be
the first member, and thus require no additional instructions to access
versus a raw pointer type).
The only reason this should perform significantly different is if you're
comparing it to a non-volatile raw pointer... and I'd be very, very
suspicious of using a non-volatile raw pointer that may be written in
another thread.
--
Matthew
More information about the Development
mailing list