Package: qtbase-opensource-src / 5.15.8+dfsg-11+deb12u3

revert_startBlocking_removal.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
Description: revert "Remove the dead code for blocking methods from QtConcurrent"
 It's a binary incompatible change.
Origin: KDE, https://invent.kde.org/qt/qt/qtbase/-/commit/eeadc036d77b75be
 Also submitted to upstream 5.15 branch according to
 https://lists.qt-project.org/pipermail/development/2022-September/042951.html.
Last-Update: 2022-09-10

--- a/src/concurrent/qtconcurrentthreadengine.cpp
+++ b/src/concurrent/qtconcurrentthreadengine.cpp
@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThread
     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();
--- a/src/concurrent/qtconcurrentthreadengine.h
+++ b/src/concurrent/qtconcurrentthreadengine.h
@@ -91,6 +91,7 @@ public:
     ThreadEngineBase();
     virtual ~ThreadEngineBase();
     void startSingleThreaded();
+    void startBlocking();
     void startThread();
     bool isCanceled();
     void waitForResume();
@@ -144,6 +145,15 @@ public:
     }
 
     // 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()
     {
@@ -223,6 +233,13 @@ class ThreadEngineStarter : public Threa
 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.
@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public
 public:
     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
         : ThreadEngineStarterBase<void>(_threadEngine) {}
+
+    void startBlocking()
+    {
+        this->threadEngine->startBlocking();
+        delete this->threadEngine;
+    }
 };
 
 //! [qtconcurrentthreadengine-1]