1// qthreadpool.sip generated by MetaSIP 2// 3// This file is part of the QtCore Python extension module. 4// 5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com> 6// 7// This file is part of PyQt5. 8// 9// This file may be used under the terms of the GNU General Public License 10// version 3.0 as published by the Free Software Foundation and appearing in 11// the file LICENSE included in the packaging of this file. Please review the 12// following information to ensure the GNU General Public License version 3.0 13// requirements will be met: http://www.gnu.org/copyleft/gpl.html. 14// 15// If you do not wish to use this file under the terms of the GPL version 3.0 16// then you may purchase a commercial license. For more information contact 17// info@riverbankcomputing.com. 18// 19// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 22 23class QThreadPool : QObject 24{ 25%TypeHeaderCode 26#include <qthreadpool.h> 27%End 28 29public: 30 QThreadPool(QObject *parent /TransferThis/ = 0); 31 virtual ~QThreadPool(); 32 static QThreadPool *globalInstance() /KeepReference/; 33 void start(QRunnable *runnable /GetWrapper/, int priority = 0) /ReleaseGIL/; 34%MethodCode 35 // We have to handle the object ownership manually. 36 if (a0->autoDelete()) 37 sipTransferTo(a0Wrapper, sipSelf); 38 39 Py_BEGIN_ALLOW_THREADS 40 sipCpp->start(a0, a1); 41 Py_END_ALLOW_THREADS 42%End 43 44%If (Qt_5_15_0 -) 45 void start(SIP_PYCALLABLE functionToRun /TypeHint="Callable[[], None]"/, int priority = 0) /ReleaseGIL/; 46%MethodCode 47 Py_INCREF(a0); 48 49 Py_BEGIN_ALLOW_THREADS 50 51 sipCpp->start([a0]() { 52 SIP_BLOCK_THREADS 53 54 PyObject *res; 55 56 res = PyObject_CallObject(a0, NULL); 57 58 Py_DECREF(a0); 59 60 if (res) 61 Py_DECREF(res); 62 else 63 pyqt5_err_print(); 64 65 SIP_UNBLOCK_THREADS 66 }, a1); 67 68 Py_END_ALLOW_THREADS 69%End 70 71%End 72 bool tryStart(QRunnable *runnable /GetWrapper/) /ReleaseGIL/; 73%MethodCode 74 // We have to handle the object ownership manually. 75 if (a0->autoDelete()) 76 sipTransferTo(a0Wrapper, sipSelf); 77 78 Py_BEGIN_ALLOW_THREADS 79 sipRes = sipCpp->tryStart(a0); 80 Py_END_ALLOW_THREADS 81%End 82 83%If (Qt_5_15_0 -) 84 bool tryStart(SIP_PYCALLABLE functionToRun /TypeHint="Callable[[], None]"/) /ReleaseGIL/; 85%MethodCode 86 Py_INCREF(a0); 87 88 Py_BEGIN_ALLOW_THREADS 89 90 sipRes = sipCpp->tryStart([a0]() { 91 SIP_BLOCK_THREADS 92 93 PyObject *res; 94 95 res = PyObject_CallObject(a0, NULL); 96 97 Py_DECREF(a0); 98 99 if (res) 100 Py_DECREF(res); 101 else 102 pyqt5_err_print(); 103 104 SIP_UNBLOCK_THREADS 105 }); 106 107 Py_END_ALLOW_THREADS 108%End 109 110%End 111%If (Qt_5_9_0 -) 112 bool tryTake(QRunnable *runnable /GetWrapper/) /ReleaseGIL/; 113%MethodCode 114 Py_BEGIN_ALLOW_THREADS 115 sipRes = sipCpp->tryTake(a0); 116 Py_END_ALLOW_THREADS 117 118 // We have to handle the object ownership manually. 119 if (sipRes) 120 sipTransferBack(a0Wrapper); 121%End 122 123%End 124 int expiryTimeout() const; 125 void setExpiryTimeout(int expiryTimeout); 126 int maxThreadCount() const; 127 void setMaxThreadCount(int maxThreadCount) /ReleaseGIL/; 128 int activeThreadCount() const /ReleaseGIL/; 129 void reserveThread() /ReleaseGIL/; 130 void releaseThread() /ReleaseGIL/; 131 bool waitForDone(int msecs = -1) /ReleaseGIL/; 132%If (Qt_5_2_0 -) 133 void clear() /ReleaseGIL/; 134%End 135%If (Qt_5_5_0 -) 136 void cancel(QRunnable *runnable) /ReleaseGIL/; 137%End 138%If (Qt_5_10_0 -) 139 void setStackSize(uint stackSize); 140%End 141%If (Qt_5_10_0 -) 142 uint stackSize() const; 143%End 144}; 145