Changeset 57629 in vbox
- Timestamp:
- Sep 4, 2015 1:07:46 PM (9 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
-
globals/UIThreadPool.cpp (modified) (3 diffs)
-
globals/UIThreadPool.h (modified) (5 diffs)
-
medium/UIMediumEnumerator.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIThreadPool.cpp
r57626 r57629 114 114 } 115 115 116 bool UIThreadPool::isTerminating() const 117 { 118 /* Acquire termination-flag: */ 119 m_everythingLocker.lock(); 120 bool fTerminating = m_fTerminating; 121 m_everythingLocker.unlock(); 122 123 return fTerminating; 124 } 125 126 void UIThreadPool::setTerminating() 127 { 128 m_everythingLocker.lock(); 129 130 /* Indicate that we're terminating: */ 131 m_fTerminating = true; 132 133 /* Tell all threads to NOT queue any termination signals: */ 134 for (int idxWorker = 0; idxWorker < m_workers.size(); ++idxWorker) 135 { 136 UIThreadWorker *pWorker = m_workers[idxWorker]; 137 if (pWorker) 138 pWorker->setNoFinishedSignal(); 139 } 140 141 /* Wake up all idle worker threads: */ 142 m_taskCondition.wakeAll(); 143 144 m_everythingLocker.unlock(); 145 } 146 116 147 void UIThreadPool::enqueueTask(UITask *pTask) 117 148 { … … 156 187 } 157 188 158 /**159 * Checks if the thread pool is terminating.160 *161 * @returns @c true if terminating, @c false if not.162 * @note Do NOT call this while owning the thread pool mutex!163 */164 bool UIThreadPool::isTerminating() const165 {166 /* Acquire termination-flag: */167 m_everythingLocker.lock();168 bool fTerminating = m_fTerminating;169 m_everythingLocker.unlock();170 171 return fTerminating;172 }173 174 void UIThreadPool::setTerminating()175 {176 m_everythingLocker.lock();177 178 /* Indicate that we're terminating: */179 m_fTerminating = true;180 181 /* Tell all threads to NOT queue any termination signals: */182 for (int idxWorker = 0; idxWorker < m_workers.size(); ++idxWorker)183 {184 UIThreadWorker *pWorker = m_workers[idxWorker];185 if (pWorker)186 pWorker->setNoFinishedSignal();187 }188 189 /* Wake up all idle worker threads: */190 m_taskCondition.wakeAll();191 192 m_everythingLocker.unlock();193 }194 195 189 UITask* UIThreadPool::dequeueTask(UIThreadWorker *pWorker) 196 190 { … … 263 257 } 264 258 265 const QVariant& UITask::data() const266 {267 return m_data;268 }269 270 259 void UITask::start() 271 260 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIThreadPool.h
r57626 r57629 52 52 ~UIThreadPool(); 53 53 54 /** Enqueues @a pTask into the task-queue. */55 void enqueueTask(UITask *pTask);56 57 54 /** Returns whether the 'termination sequence' is started. */ 58 55 bool isTerminating() const; … … 60 57 void setTerminating(); 61 58 62 protected: 63 59 /** Enqueues @a pTask into the task-queue. */ 60 void enqueueTask(UITask *pTask); 64 61 /** Returns dequeued top-most task from the task-queue. 65 62 * @remarks Called by the @a pWorker passed as a hint. */ … … 109 106 * all the inter-thread variables. */ 110 107 mutable QMutex m_everythingLocker; 111 112 /** Allows UIThreadWorker to dequeue tasks. */113 friend class UIThreadWorker;114 108 }; 115 109 … … 133 127 134 128 /** Returns the inter-thread task data. */ 135 const QVariant& data() const; 129 const QVariant& data() const { return m_data; } 130 /** Defines the inter-thread task @a data. */ 131 void setData(const QVariant &data) { m_data = data; } 132 133 /** Starts the task. */ 134 void start(); 136 135 137 136 protected: 138 139 /** Starts the task.140 * @remarks Called by the worker-thread. */141 void start();142 137 143 138 /** Contains the abstract task body. … … 145 140 virtual void run() = 0; 146 141 147 //private:142 private: 148 143 149 144 /** Holds the inter-thread task data. */ 150 145 QVariant m_data; 151 152 /** Allows UIThreadWorker to start task. */153 friend class UIThreadWorker;154 146 }; 155 147 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumEnumerator.cpp
r57611 r57629 61 61 { 62 62 /* Get medium: */ 63 UIMedium medium = m_data.value<UIMedium>();63 UIMedium medium = data().value<UIMedium>(); 64 64 /* Enumerate it: */ 65 65 medium.blockAndQueryState(); 66 66 /* Put medium back: */ 67 m_data = QVariant::fromValue(medium);67 setData(QVariant::fromValue(medium)); 68 68 } 69 69
Note:
See TracChangeset
for help on using the changeset viewer.

