[Development] Evolving Qt's multithreading API

Olivier Goffart olivier at woboq.com
Fri Feb 22 15:21:50 CET 2013


On Friday 22 February 2013 18:57:29 Sze Howe Koh wrote:

> I meant variadic templates and std::bind. QtConcurrent::run() uses a
> code generator to produce 6 separate templates. In theory, we can
> replace all that with 1 variadic template. No code generator, fewer
> templates, less maintenance.
> 
>     template <typename TFunc, typename... TArgs>
>     static QThread* setupSimpleThread(TFunc&& func, TArgs&&... args)
>     {
>         // Private class, derived from QThread
>         return new QFunctionThread(
>                 std::bind(std::forward<TFunction>(a_func),
>                         std::forward<TArgs>(a_args)...));
>     }
> 
> We do have many older compilers to support still. Is Qt ready to start
> introducing features that require C++11? Are we in a position to drive
> its adoption, as Thiago put it?
> (http://www.macieira.org/blog/2011/09/cxx11-support-in-qt-5/)

Variadic template, we can clearly not rely on it.  It only came in MSVC really 
recently (patch release in nov 2012)

However, std::function and std::bind were already in tr1,  which AFAIK is 
already supported by all the compiler we support (Tier1 + Tier2) (MSVC 2008 
and gcc 4.2 have it)

-- 
Olivier 

Woboq - Qt services and support - http://woboq.com - http://code.woboq.org




More information about the Development mailing list