1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2008-2012 NVIDIA Corporation. 4 ** Copyright (C) 2019 The Qt Company Ltd. 5 ** Contact: https://www.qt.io/licensing/ 6 ** 7 ** This file is part of Qt Quick 3D. 8 ** 9 ** $QT_BEGIN_LICENSE:GPL$ 10 ** Commercial License Usage 11 ** Licensees holding valid commercial Qt licenses may use this file in 12 ** accordance with the commercial license agreement provided with the 13 ** Software or, alternatively, in accordance with the terms contained in 14 ** a written agreement between you and The Qt Company. For licensing terms 15 ** and conditions see https://www.qt.io/terms-conditions. For further 16 ** information use the contact form at https://www.qt.io/contact-us. 17 ** 18 ** GNU General Public License Usage 19 ** Alternatively, this file may be used under the terms of the GNU 20 ** General Public License version 3 or (at your option) any later version 21 ** approved by the KDE Free Qt Foundation. The licenses are as published by 22 ** the Free Software Foundation and appearing in the file LICENSE.GPL3 23 ** included in the packaging of this file. Please review the following 24 ** information to ensure the GNU General Public License requirements will 25 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 26 ** 27 ** $QT_END_LICENSE$ 28 ** 29 ****************************************************************************/ 30 31 #ifndef QSSG_RENDER_THREAD_POOL_H 32 #define QSSG_RENDER_THREAD_POOL_H 33 34 // 35 // W A R N I N G 36 // ------------- 37 // 38 // This file is not part of the Qt API. It exists purely as an 39 // implementation detail. This header file may change from version to 40 // version without notice, or even be removed. 41 // 42 // We mean it. 43 // 44 45 #include <QtQuick3DRuntimeRender/private/qtquick3druntimerenderglobal_p.h> 46 47 #include <QtCore/QSharedPointer> 48 49 QT_BEGIN_NAMESPACE 50 51 using QSSGTaskCallback = void (*)(void *); 52 53 enum class TaskStates 54 { 55 UnknownTask = 0, 56 Queued, 57 Running, 58 }; 59 60 enum class CancelReturnValues 61 { 62 TaskCanceled = 0, 63 TaskRunning, 64 TaskNotFound, 65 }; 66 67 class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGAbstractThreadPool 68 { 69 public: 70 QAtomicInt ref; 71 virtual ~QSSGAbstractThreadPool(); 72 // Add a task to be run at some point in the future. 73 // Tasks will be run roughly in order they are given. 74 // The returned value is a handle that can be used to query 75 // details about the task 76 // Cancel function will be called if the thread pool is destroyed or 77 // of the task gets canceled. 78 virtual quint64 addTask(void *inUserData, QSSGTaskCallback inFunction, QSSGTaskCallback inCancelFunction) = 0; 79 virtual TaskStates getTaskState(quint64 inTaskId) = 0; 80 virtual CancelReturnValues cancelTask(quint64 inTaskId) = 0; 81 82 static QSSGRef<QSSGAbstractThreadPool> createThreadPool(qint32 inNumThreads = 4); 83 }; 84 QT_END_NAMESPACE 85 #endif 86