Introducing Qt Concurrent

· by admin · 1 min read · original post ↗

·

As a part of Trolltech Labs, I’m adding the Qt Concurrent project. Qt Concurrent is a high-level threading framework for writing code that automatically scales on multi-core systems.

For example, to make thumbnails of a list of images you can do this:


QImage scaled(const QImage &image)  

{  

    return image.scaled(QSize(100, 100));  

}

...



const QList<QImage> images = ...  

const QList<QImage> thumbnails = QtConcurrent::mapped(images, scaled);

QtConcurrent::mapped() runs scaled() on each image in the list, using as many threads as there are CPU cores on the system.

In addition to this Qt Concurrent also provides a MapReduce implementation for shared-memory systems and support for making asynchronous function calls using futures.

You can get the source code at the labs pages, and there is also a forum for questions and general feedback.

LabsQt ConcurrentThreads

More on Qt Concurrent

More from admin