finish();
}
+void ThreadEngineBase::startBlocking()
+{
+ start();
+ barrier.acquire();
+ startThreads();
+
+ bool throttled = false;
+#ifndef QT_NO_EXCEPTIONS
+ try {
+#endif
+ while (threadFunction() == ThrottleThread) {
+ if (threadThrottleExit()) {
+ throttled = true;
+ break;
+ }
+ }
+#ifndef QT_NO_EXCEPTIONS
+ } catch (QException &e) {
+ handleException(e);
+ } catch (...) {
+ handleException(QUnhandledException());
+ }
+#endif
+
+ if (throttled == false) {
+ barrier.release();
+ }
+
+ barrier.wait();
+ finish();
+ exceptionStore.throwPossibleException();
+}
+
void ThreadEngineBase::startThread()
{
startThreadInternal();
ThreadEngineBase();
virtual ~ThreadEngineBase();
void startSingleThreaded();
+ void startBlocking();
void startThread();
bool isCanceled();
void waitForResume();
return result();
}
+ // Runs the user algorithm using multiple threads.
+ // This function blocks until the algorithm is finished,
+ // and then returns the result.
+ T *startBlocking()
+ {
+ ThreadEngineBase::startBlocking();
+ return result();
+ }
+
// Runs the user algorithm using multiple threads.
// Does not block, returns a future.
QFuture<T> startAsynchronously()
public:
ThreadEngineStarter(TypedThreadEngine *eng)
: Base(eng) { }
+
+ T startBlocking()
+ {
+ T t = *this->threadEngine->startBlocking();
+ delete this->threadEngine;
+ return t;
+ }
};
// Full template specialization where T is void.
public:
ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
: ThreadEngineStarterBase<void>(_threadEngine) {}
+
+ void startBlocking()
+ {
+ this->threadEngine->startBlocking();
+ delete this->threadEngine;
+ }
};
//! [qtconcurrentthreadengine-1]