[Development] invokeMethod() with function pointers
olivier at woboq.com
Mon Jan 16 11:21:32 CET 2017
On Montag, 16. Januar 2017 12:57:01 CET Konstantin Tokarev wrote:
> 16.01.2017, 12:34, "Olivier Goffart" <olivier at woboq.com>:
> > On Samstag, 14. Januar 2017 17:28:01 CET Benjamin TERRIER wrote:
> >> Hi everyone,
> >> I'm trying to contribute by making QMetaObject::invokeMethod() take
> >> function pointers instead of function names.
> >> I've come up with something that works by looking at the code of
> >> QMetaObject::invokeMethod, QObject::connect and QMetaObject::activate.
> > Thanks for your contribution.
> > What's the use case for this function? For direct call you better of
> > calling the function directly, and the equivalent of QueuedConnection can
> > be achieved with QTimer::singleShot.
> QTimer::singleShot creates temporary QSingleShotTimer object, which does not
> seem to be efficient solution if same method needs to be called a lot of
> times in QueuedConnection way.
Yes, that's true: The string based method is optimized for 0ms timeout, but
not the function pointer one.
The function pointer version could be optimized for 0 timer the same way that
the string version of QTimer::singleShot does.
(Well, not exactly the same way currently as we cannot use
Woboq - Qt services and support - https://woboq.com - https://code.woboq.org
More information about the Development