- Timestamp:
- Sep 9, 2015 1:30:30 PM (9 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIThreadPool.cpp
r57663 r57667 112 112 } 113 113 114 /* Cleanup all the tasks: */ 115 qDeleteAll(m_pendingTasks); 116 qDeleteAll(m_executingTasks); 117 m_pendingTasks.clear(); 118 m_executingTasks.clear(); 119 114 120 /* Unlock finally: */ 115 121 m_everythingLocker.unlock(); … … 167 173 168 174 /* Put the task into the queue: */ 169 m_ tasks.enqueue(pTask);175 m_pendingTasks.enqueue(pTask); 170 176 171 177 /* Wake up an idle worker if we got one: */ … … 216 222 217 223 /* Dequeue task if there is one: */ 218 if (!m_ tasks.isEmpty())224 if (!m_pendingTasks.isEmpty()) 219 225 { 220 UITask *pTask = m_ tasks.dequeue();226 UITask *pTask = m_pendingTasks.dequeue(); 221 227 if (pTask) 222 228 { 229 /* Put into the set of executing tasks: */ 230 m_executingTasks << pTask; 231 223 232 /* Unlock finally: */ 224 233 m_everythingLocker.unlock(); … … 259 268 return; 260 269 261 /* Notify listener : */270 /* Notify listeners: */ 262 271 emit sigTaskComplete(pTask); 272 273 /* Lock initially: */ 274 m_everythingLocker.lock(); 275 276 /* Delete task finally: */ 277 Assert(m_executingTasks.contains(pTask) && 278 m_executingTasks.remove(pTask)); 279 delete pTask; 280 281 /* Unlock finally: */ 282 m_everythingLocker.unlock(); 263 283 } 264 284 … … 296 316 { 297 317 /* Process the task if we are not terminating. 298 * Please take into account tasks are cleared by their creator. */ 318 * Please take into account tasks are cleared by the UIThreadPool 319 * after all listeners notified about task is complete and handled it. */ 299 320 if (!m_pPool->isTerminating()) 300 321 pTask->start(); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIThreadPool.h
r57664 r57667 23 23 #include <QMutex> 24 24 #include <QQueue> 25 #include <QSet> 25 26 #include <QVariant> 26 27 #include <QVector> … … 92 93 /** @name Task stuff 93 94 * @{ */ 94 /** Holds the queue (FIFO) of pending tasks. */ 95 QQueue<UITask*> m_tasks; 96 /** Holds the condition variable that gets signalled when 95 /** Holds the queue of pending tasks. */ 96 QQueue<UITask*> m_pendingTasks; 97 /** Holds the set of executing tasks. */ 98 QSet<UITask*> m_executingTasks; 99 /** Holds the condition variable that gets signalled when 97 100 * queuing a new task and there are idle worker threads around. 98 101 * @remarks Idle threads sits in dequeueTask waiting for this. -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumEnumerator.cpp
r57664 r57667 84 84 /* Listen for global thread-pool: */ 85 85 connect(vboxGlobal().threadPool(), SIGNAL(sigTaskComplete(UITask*)), this, SLOT(sltHandleMediumEnumerationTaskComplete(UITask*))); 86 }87 88 UIMediumEnumerator::~UIMediumEnumerator()89 {90 /* Delete all the tasks: */91 while (!m_tasks.isEmpty())92 delete m_tasks.takeFirst();93 86 } 94 87 … … 276 269 if (pTask->type() != UITask::Type_MediumEnumeration) 277 270 return; 278 int iIndexOfTask = m_tasks.indexOf(pTask); 279 AssertReturnVoid(iIndexOfTask != -1); 271 AssertReturnVoid(m_tasks.contains(pTask)); 280 272 281 273 /* Get enumerated UIMedium: */ … … 284 276 LogRel2(("GUI: UIMediumEnumerator: Medium with key={%s} enumerated\n", strUIMediumKey.toAscii().constData())); 285 277 286 /* Delete task: */287 delete m_tasks.takeAt(iIndexOfTask);278 /* Remove task from internal set: */ 279 m_tasks.remove(pTask); 288 280 289 281 /* Make sure such UIMedium still exists: */ … … 341 333 /* Prepare medium-enumeration task: */ 342 334 UITask *pTask = new UITaskMediumEnumeration(medium); 343 /* Append to internal list: */344 m_tasks .append(pTask);335 /* Append to internal set: */ 336 m_tasks << pTask; 345 337 /* Post into global thread-pool: */ 346 338 vboxGlobal().threadPool()->enqueueTask(pTask); -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumEnumerator.h
r57611 r57667 21 21 /* Qt includes: */ 22 22 #include <QObject> 23 #include <QSet> 23 24 24 25 /* GUI includes: */ … … 53 54 /** Constructs medium-enumerator object. */ 54 55 UIMediumEnumerator(); 55 /** Destructs medium-enumerator object. */56 ~UIMediumEnumerator();57 56 58 57 /* API: Medium-access stuff: */ … … 96 95 /* Variables: */ 97 96 bool m_fMediumEnumerationInProgress; 98 Q List<UITask*> m_tasks;97 QSet<UITask*> m_tasks; 99 98 UIMediumMap m_mediums; 100 99 };
Note:
See TracChangeset
for help on using the changeset viewer.