qthreadpool.sip 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. // qthreadpool.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtCore Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  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. class QThreadPool : public QObject
  22. {
  23. %TypeHeaderCode
  24. #include <qthreadpool.h>
  25. %End
  26. public:
  27. QThreadPool(QObject *parent /TransferThis/ = 0);
  28. virtual ~QThreadPool() /ReleaseGIL/;
  29. static QThreadPool *globalInstance() /KeepReference/;
  30. void start(QRunnable *runnable /GetWrapper/, int priority = 0) /ReleaseGIL/;
  31. %MethodCode
  32. // We have to handle the object ownership manually.
  33. if (a0->autoDelete())
  34. sipTransferTo(a0Wrapper, sipSelf);
  35. Py_BEGIN_ALLOW_THREADS
  36. sipCpp->start(a0, a1);
  37. Py_END_ALLOW_THREADS
  38. %End
  39. void start(SIP_PYCALLABLE functionToRun /TypeHint="Callable[[], None]"/, int priority = 0) /ReleaseGIL/;
  40. %MethodCode
  41. Py_INCREF(a0);
  42. Py_BEGIN_ALLOW_THREADS
  43. sipCpp->start([a0]() {
  44. SIP_BLOCK_THREADS
  45. PyObject *res;
  46. res = PyObject_CallObject(a0, NULL);
  47. Py_DECREF(a0);
  48. if (res)
  49. Py_DECREF(res);
  50. else
  51. pyqt6_err_print();
  52. SIP_UNBLOCK_THREADS
  53. }, a1);
  54. Py_END_ALLOW_THREADS
  55. %End
  56. bool tryStart(QRunnable *runnable /GetWrapper/) /ReleaseGIL/;
  57. %MethodCode
  58. // We have to handle the object ownership manually.
  59. if (a0->autoDelete())
  60. sipTransferTo(a0Wrapper, sipSelf);
  61. Py_BEGIN_ALLOW_THREADS
  62. sipRes = sipCpp->tryStart(a0);
  63. Py_END_ALLOW_THREADS
  64. %End
  65. bool tryStart(SIP_PYCALLABLE functionToRun /TypeHint="Callable[[], None]"/) /ReleaseGIL/;
  66. %MethodCode
  67. Py_INCREF(a0);
  68. Py_BEGIN_ALLOW_THREADS
  69. sipRes = sipCpp->tryStart([a0]() {
  70. SIP_BLOCK_THREADS
  71. PyObject *res;
  72. res = PyObject_CallObject(a0, NULL);
  73. Py_DECREF(a0);
  74. if (res)
  75. Py_DECREF(res);
  76. else
  77. pyqt6_err_print();
  78. SIP_UNBLOCK_THREADS
  79. });
  80. Py_END_ALLOW_THREADS
  81. %End
  82. bool tryTake(QRunnable *runnable /GetWrapper/) /ReleaseGIL/;
  83. %MethodCode
  84. Py_BEGIN_ALLOW_THREADS
  85. sipRes = sipCpp->tryTake(a0);
  86. Py_END_ALLOW_THREADS
  87. // We have to handle the object ownership manually.
  88. if (sipRes)
  89. sipTransferBack(a0Wrapper);
  90. %End
  91. int expiryTimeout() const;
  92. void setExpiryTimeout(int expiryTimeout);
  93. int maxThreadCount() const;
  94. void setMaxThreadCount(int maxThreadCount) /ReleaseGIL/;
  95. int activeThreadCount() const /ReleaseGIL/;
  96. void reserveThread() /ReleaseGIL/;
  97. void releaseThread() /ReleaseGIL/;
  98. %If (Qt_6_8_0 -)
  99. bool waitForDone(QDeadlineTimer deadline) /ReleaseGIL/ [bool (QDeadlineTimer deadline = QDeadlineTimer::Forever)];
  100. %End
  101. bool waitForDone(int msecs = -1) /ReleaseGIL/;
  102. void clear() /ReleaseGIL/;
  103. void setStackSize(uint stackSize);
  104. uint stackSize() const;
  105. bool contains(const QThread *thread) const;
  106. %If (Qt_6_2_0 -)
  107. void setThreadPriority(QThread::Priority priority);
  108. %End
  109. %If (Qt_6_2_0 -)
  110. QThread::Priority threadPriority() const;
  111. %End
  112. %If (Qt_6_3_0 -)
  113. void startOnReservedThread(QRunnable *runnable /GetWrapper/) /ReleaseGIL/;
  114. %MethodCode
  115. // We have to handle the object ownership manually.
  116. if (a0->autoDelete())
  117. sipTransferTo(a0Wrapper, sipSelf);
  118. Py_BEGIN_ALLOW_THREADS
  119. sipCpp->startOnReservedThread(a0);
  120. Py_END_ALLOW_THREADS
  121. %End
  122. %End
  123. %If (Qt_6_3_0 -)
  124. void startOnReservedThread(SIP_PYCALLABLE functionToRun /TypeHint="Callable[[], None]"/) /ReleaseGIL/;
  125. %MethodCode
  126. Py_INCREF(a0);
  127. Py_BEGIN_ALLOW_THREADS
  128. sipCpp->startOnReservedThread([a0]() {
  129. SIP_BLOCK_THREADS
  130. PyObject *res;
  131. res = PyObject_CallObject(a0, NULL);
  132. Py_DECREF(a0);
  133. if (res)
  134. Py_DECREF(res);
  135. else
  136. pyqt6_err_print();
  137. SIP_UNBLOCK_THREADS
  138. });
  139. Py_END_ALLOW_THREADS
  140. %End
  141. %End
  142. %If (Qt_6_9_0 -)
  143. void setServiceLevel(QThread::QualityOfService serviceLevel);
  144. %End
  145. %If (Qt_6_9_0 -)
  146. QThread::QualityOfService serviceLevel() const;
  147. %End
  148. };