1 /* 2 * DQt - D bindings for the Qt Toolkit 3 * 4 * GNU Lesser General Public License Usage 5 * This file may be used under the terms of the GNU Lesser 6 * General Public License version 3 as published by the Free Software 7 * Foundation and appearing in the file LICENSE.LGPL3 included in the 8 * packaging of this file. Please review the following information to 9 * ensure the GNU Lesser General Public License version 3 requirements 10 * will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 11 */ 12 module qt.core.threadpool; 13 extern(C++): 14 15 import qt.config; 16 import qt.core.object; 17 import qt.core.runnable; 18 import qt.core.thread; 19 import qt.helpers; 20 21 /+ QT_REQUIRE_CONFIG(thread); +/ 22 23 24 extern(C++, class) struct QThreadPoolPrivate; 25 /// Binding for C++ class [QThreadPool](https://doc.qt.io/qt-6/qthreadpool.html). 26 class /+ Q_CORE_EXPORT +/ QThreadPool : QObject 27 { 28 mixin(Q_OBJECT); 29 /+ Q_DECLARE_PRIVATE(QThreadPool) +/ 30 /+ Q_PROPERTY(int expiryTimeout READ expiryTimeout WRITE setExpiryTimeout) 31 Q_PROPERTY(int maxThreadCount READ maxThreadCount WRITE setMaxThreadCount) 32 Q_PROPERTY(int activeThreadCount READ activeThreadCount) 33 Q_PROPERTY(uint stackSize READ stackSize WRITE setStackSize) 34 Q_PROPERTY(QThread::Priority threadPriority READ threadPriority WRITE setThreadPriority) +/ 35 /+ friend class QFutureInterfaceBase; +/ 36 37 public: 38 this(QObject parent = null); 39 ~this(); 40 41 static QThreadPool globalInstance(); 42 43 final void start(QRunnable runnable, int priority = 0); 44 final bool tryStart(QRunnable runnable); 45 46 /+ void start(std::function<void()> functionToRun, int priority = 0); +/ 47 /+ bool tryStart(std::function<void()> functionToRun); +/ 48 49 final int expiryTimeout() const; 50 final void setExpiryTimeout(int expiryTimeout); 51 52 final int maxThreadCount() const; 53 final void setMaxThreadCount(int maxThreadCount); 54 55 final int activeThreadCount() const; 56 57 final void setStackSize(uint stackSize); 58 final uint stackSize() const; 59 60 final void setThreadPriority(QThread.Priority priority); 61 final QThread.Priority threadPriority() const; 62 63 final void reserveThread(); 64 final void releaseThread(); 65 66 final bool waitForDone(int msecs = -1); 67 68 final void clear(); 69 70 mixin(changeWindowsMangling(q{mangleClassesTailConst}, q{ 71 final bool contains(const(QThread) thread) const; 72 })); 73 74 /+ [[nodiscard]] +/ final bool tryTake(QRunnable runnable); 75 mixin(CREATE_CONVENIENCE_WRAPPERS); 76 } 77