Changeset 71526 in vbox
- Timestamp:
- Mar 27, 2018 4:01:42 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/globals
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIThreadPool.cpp
r69500 r71526 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 25 25 /* GUI includes: */ 26 26 # include "COMDefs.h" 27 # include "UIDefs.h" 27 28 # include "UIThreadPool.h" 28 # include "UIDefs.h"29 29 30 30 /* Other VBox includes: */ … … 32 32 33 33 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 34 34 35 35 36 /** QThread extension used as worker-thread. … … 47 48 48 49 /** Constructs worker-thread for parent worker-thread @a pPool. 49 * @param iIndex defines worker-thread index within the worker-thread pool registry. */50 * @param iIndex Brings worker-thread index within the worker-thread pool registry. */ 50 51 UIThreadWorker(UIThreadPool *pPool, int iIndex); 51 52 … … 70 71 bool m_fNoFinishedSignal; 71 72 }; 73 74 75 /********************************************************************************************************************************* 76 * Class UIThreadPool implementation. * 77 *********************************************************************************************************************************/ 72 78 73 79 UIThreadPool::UIThreadPool(ulong cMaxWorkers /* = 3 */, ulong cMsWorkerIdleTimeout /* = 5000 */) … … 207 213 } 208 214 209 UITask *UIThreadPool::dequeueTask(UIThreadWorker *pWorker)215 UITask *UIThreadPool::dequeueTask(UIThreadWorker *pWorker) 210 216 { 211 217 /* Lock initially: */ … … 301 307 } 302 308 309 310 /********************************************************************************************************************************* 311 * Class UIThreadWorker implementation. * 312 *********************************************************************************************************************************/ 313 303 314 UIThreadWorker::UIThreadWorker(UIThreadPool *pPool, int iIndex) 304 315 : m_pPool(pPool) … … 332 343 } 333 344 345 334 346 #include "UIThreadPool.moc" 335 347 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIThreadPool.h
r69500 r71526 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 21 21 /* Qt includes: */ 22 #include <QMutex> 22 23 #include <QObject> 23 #include <QMutex>24 24 #include <QQueue> 25 25 #include <QSet> … … 29 29 30 30 /* Forward declarations: */ 31 class UITask; 31 32 class UIThreadWorker; 32 class UITask; 33 33 34 34 35 /** QObject extension used as worker-thread pool. … … 46 47 47 48 /** Constructs worker-thread pool. 48 * @param cMaxWorkers defines the maximum amount of worker-threads.49 * @param cMsWorkerIdleTimeout defines the maximum amount of time (in ms) which50 * pool will wait for the worker-thread on cleanup. */49 * @param cMaxWorkers Brings the maximum amount of worker-threads. 50 * @param cMsWorkerIdleTimeout Brings the maximum amount of time (in ms) which 51 * pool will wait for the worker-thread on cleanup. */ 51 52 UIThreadPool(ulong cMaxWorkers = 3, ulong cMsWorkerIdleTimeout = 5000); 52 53 /** Destructs worker-thread pool. */ … … 60 61 /** Enqueues @a pTask into the task-queue. */ 61 62 void enqueueTask(UITask *pTask); 62 /** Returns dequeued top-most task from the task-queue. 63 * @remarks Called by the @a pWorker passed as a hint. */ 64 UITask* dequeueTask(UIThreadWorker *pWorker); 63 /** Returns dequeued top-most task from the task-queue. */ 64 UITask *dequeueTask(UIThreadWorker *pWorker); 65 65 66 66 private slots: … … 78 78 /** Holds the maximum amount of time (in ms) which 79 79 * pool will wait for the worker-thread on cleanup. */ 80 const ulong m_cMsIdleTimeout;80 const ulong m_cMsIdleTimeout; 81 81 /** Holds the vector of worker-threads. */ 82 QVector<UIThreadWorker*> m_workers;82 QVector<UIThreadWorker*> m_workers; 83 83 /** Holds the number of worker-threads. 84 84 * @remarks We cannot use the vector size since it may contain 0 pointers. */ 85 int m_cWorkers;85 int m_cWorkers; 86 86 /** Holds the number of idle worker-threads. */ 87 int m_cIdleWorkers;87 int m_cIdleWorkers; 88 88 /** Holds whether the 'termination sequence' is started 89 89 * and all worker-threads should terminate ASAP. */ 90 bool m_fTerminating;90 bool m_fTerminating; 91 91 /** @} */ 92 92 … … 94 94 * @{ */ 95 95 /** Holds the queue of pending tasks. */ 96 QQueue<UITask*> m_pendingTasks;96 QQueue<UITask*> m_pendingTasks; 97 97 /** Holds the set of executing tasks. */ 98 QSet<UITask*> m_executingTasks;98 QSet<UITask*> m_executingTasks; 99 99 /** Holds the condition variable that gets signalled when 100 100 * queuing a new task and there are idle worker threads around. … … 103 103 * broadcast signal to wake up all workers (after 104 104 * setting m_fTerminating of course). */ 105 QWaitCondition m_taskCondition;105 QWaitCondition m_taskCondition; 106 106 /** @} */ 107 107 … … 110 110 mutable QMutex m_everythingLocker; 111 111 }; 112 112 113 113 114 /** QObject extension used as worker-thread task interface. … … 131 132 }; 132 133 133 /** Constructs the task of passed @a type. */134 UITask(UITask::Type type) : m_type(type) {}134 /** Constructs the task of passed @a enmType. */ 135 UITask(UITask::Type enmType) : m_enmType(enmType) {} 135 136 136 137 /** Returns the type of the task. */ 137 UITask::Type type() const { return m_ type; }138 UITask::Type type() const { return m_enmType; } 138 139 139 140 /** Starts the task. */ … … 142 143 protected: 143 144 144 /** Contains the abstract task body. 145 * @remarks To be reimplemented in sub-class. */ 145 /** Contains the abstract task body. */ 146 146 virtual void run() = 0; 147 147 … … 149 149 150 150 /** Holds the type of the task. */ 151 const UITask::Type m_ type;151 const UITask::Type m_enmType; 152 152 }; 153 153 154 154 155 #endif /* !___UIThreadPool_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.