Questions tagged [qtconcurrent]

QtConcurrent is a Qt framework namespace providing high-level multithreading APIs.

QtConcurrent namespace was introduced in Qt 4.4. The QtConcurrent namespace provides high-level APIs that make it possible to write multi-threaded programs without using low-level threading primitives such as mutexes, read-write locks, wait conditions, or semaphores.

As of Qt 4.8.0, it includes:

  • 2 Classes
  • 2 Types
  • and mostly Functions

As of Qt 5, it became a separate add-on module, and includes:

  • QtConcurrent namespace
  • QFuture
  • QFutureIterator
  • QFutureWatcher
  • QFutureSynchronizer

Details can be found on the following page.

Resources:

193 questions
4
votes
0 answers

Is there any way to terminate QtConcurrent API while running?

Normal QThread can be terminated using terminate() Slot, thread will terminates based on platform which thread running and based on OS scheduling settings/policies. I know it is not wise to terminate a thread. My questine is can anyone know is there…
Ashif
  • 1,652
  • 14
  • 30
4
votes
1 answer

QtConcurrent blockingMappedReduced v.s MappedReduced

From my understanding QtConcurrent::blockingMappedReduced returns the final results, whereas QtConcurrent::MappedReduced returns a QFuture object, but in this example http://doc.qt.io/qt-5/qtconcurrent-wordcount-main-cpp.html I saw code like…
ascetic652
  • 472
  • 1
  • 5
  • 18
4
votes
2 answers

How can I run my Qt function after a thread has finished?

void MainWindow::on_pushButton_clicked() { QFuture future = QtConcurrent::run(identify); //Thread1 if (future.isFinished()) { //DoSomething(); } } I have this code. I want to run the DoSomething() function after the…
Nemeth Attila
  • 133
  • 2
  • 13
4
votes
1 answer

How does QtConcurrent::run wind up on main thread?

I've built a QFuture based asynchronous networking facade in my application. Roughly it works like this: namespace NetworkFacade { QByteArray syncGet(const QUrl& url) { QEventLoop l; QByteArray rc; get(url, [&](const…
Tim
  • 4,560
  • 2
  • 40
  • 64
4
votes
1 answer

What is the purpose of QException?

In Qt 5.0 - Qt Introduced the QException class. What is benifit of inheriting from this class? What if we throw a class that does not inherit from the QException class? Thank you in advance!
DesignIsLife
  • 510
  • 5
  • 11
4
votes
1 answer

QFutureWatcher not calling connected slot

I have the following code which implements QtConcurrent::run() with QFutureWatcher to start the fetch() function which runs a shell process. Upon completion, I want to call the writeDesc function, but it never gets called. void…
Aakash Jain
  • 1,963
  • 17
  • 29
4
votes
2 answers

Qt QTcpSocket with QtConcurrent::run Needs Event Loop in Separate Thread

I have a web server in Qt that will read a very large ( ~1Gb ) file and return the data to the requestor through a QTcpSocket. This socket is created by the main server thread. I want to use QtConcurrent to hand off this socket to a worker thread…
PhilBot
  • 748
  • 18
  • 85
  • 173
4
votes
1 answer

Thread id of QtConcurrent run

I am doing multi-thread programs with QT. I use this code to try whether it acts as i expected. QFuture t1 = QtConcurrent::run(thread_process1, (void *)this); QFuture t2 = QtConcurrent::run(thread_process2, (void *)this); and both…
楊惟鈞
  • 622
  • 6
  • 12
3
votes
2 answers

Connecting signals/slots on separate thread using QtConcurrent::run

In my application I have the following code in a dialog: connect(drive, SIGNAL(FileProgressChanged(Progress)), SLOT(OnFileProgressChanged(Progress))); QtConcurrent::run(this, &ProgressDialog::PerformOperation, Operation, *Path, OutPath,…
Lander
  • 3,369
  • 2
  • 37
  • 53
3
votes
1 answer

Qt::Concurrent mapped with a member function

I want to use the QtConcurrent::mapped() function, but going through the QtConcurrent examples provided and trying to find a usable example to extend to my use has been difficult. In the examples, Qt maps to static functions only, no member…
CybeX
  • 2,060
  • 3
  • 48
  • 115
3
votes
2 answers

How to terminate async function when the Qt dialog is closed

Background I have a dialog which runs a time-consuming operation on its initialization. I wrapped this operation into an asynchronous function in order not to freeze the GUI. Example Imagine a dialog/widget which shows the current weather fetched…
John Doe
  • 555
  • 6
  • 17
3
votes
2 answers

QtConcurrent: why releaseThread and reserveThread cause deadlock?

In Qt 4.7 Reference for QThreadPool, we find: void QThreadPool::releaseThread() Releases a thread previously reserved by a call to reserveThread(). Note: Calling this function without previously reserving a thread temporarily increases…
3
votes
1 answer

How to create a QFuture with an immediately available value?

I have a function which returns QFuture object as a result of a QtConcurrent::run computation. However, there could be some conditions before running the concurrent method where I need to manually return a value-holding future from my…
John Doe
  • 555
  • 6
  • 17
3
votes
1 answer

QtConcurrent::map shows no benefit

I want to manipulate a QVector using the QtConcurrent::map function. All my sample program does is to increment all values in a QVector by 1. QVector arr(10000000, 0); QElapsedTimer timer; qDebug() <<…
3
votes
2 answers

QFutureWatcher how to watch multiple tasks/futures and finished() signals

I have some tasks, started with QtConcurrent::run(). Tasks has QFutureWatcher. I know that QFutureWatcher can watch only one Future, but when I started the same tasks from UI, how can I create `QFutureWatcher* on each task? Is it…
Meteo ir3
  • 449
  • 8
  • 21
1
2
3
12 13