Changeset 60448 in vbox
- Timestamp:
- Apr 12, 2016 10:26:56 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 106535
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/VFSExplorerImpl.h
r59577 r60448 70 70 ////////////////////////////////////////////////////////////////////////////////// 71 71 // 72 structTaskVFSExplorer; /* Worker thread helper */72 class TaskVFSExplorer; /* Worker thread helper */ 73 73 struct Data; 74 74 Data *m; -
trunk/src/VBox/Main/src-server/VFSExplorerImpl.cpp
r59577 r60448 33 33 #include "AutoCaller.h" 34 34 #include "Logging.h" 35 #include "ThreadTask.h" 35 36 36 37 #include <memory> … … 149 150 } 150 151 151 struct VFSExplorer::TaskVFSExplorer 152 { 152 class VFSExplorer::TaskVFSExplorer : public ThreadTask 153 { 154 public: 153 155 enum TaskType 154 156 { … … 162 164 progress(aProgress), 163 165 rc(S_OK) 164 {} 166 { 167 m_strTaskName = "Explorer::Task"; 168 } 165 169 ~TaskVFSExplorer() {} 166 170 167 int startThread(); 171 private: 172 void handler() 173 { 174 int vrc = taskThread(NULL, this); 175 } 176 168 177 static DECLCALLBACK(int) taskThread(RTTHREAD aThread, void *pvUser); 169 178 static DECLCALLBACK(int) uploadProgress(unsigned uPercent, void *pvUser); … … 171 180 TaskType taskType; 172 181 VFSExplorer *pVFSExplorer; 182 173 183 ComObjPtr<Progress> progress; 174 184 HRESULT rc; … … 176 186 /* task data */ 177 187 std::list<Utf8Str> filenames; 188 189 friend class VFSExplorer; 178 190 }; 179 180 int VFSExplorer::TaskVFSExplorer::startThread()181 {182 int vrc = RTThreadCreate(NULL, VFSExplorer::TaskVFSExplorer::taskThread, this,183 0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,184 "Explorer::Task");185 186 if (RT_FAILURE(vrc))187 return VFSExplorer::setErrorStatic(E_FAIL, Utf8StrFmt("Could not create taskThreadVFS (%Rrc)\n", vrc));188 189 return vrc;190 }191 191 192 192 /* static */ 193 193 DECLCALLBACK(int) VFSExplorer::TaskVFSExplorer::taskThread(RTTHREAD /* aThread */, void *pvUser) 194 194 { 195 std::auto_ptr<TaskVFSExplorer> task(static_cast<TaskVFSExplorer*>(pvUser));196 AssertReturn( task.get(), VERR_GENERAL_FAILURE);197 198 VFSExplorer *pVFSExplorer = task->pVFSExplorer;195 TaskVFSExplorer* pTask = static_cast<TaskVFSExplorer*>(pvUser); 196 AssertReturn(pTask, VERR_GENERAL_FAILURE); 197 198 VFSExplorer *pVFSExplorer = pTask->pVFSExplorer; 199 199 200 200 LogFlowFuncEnter(); … … 203 203 HRESULT rc = S_OK; 204 204 205 switch( task->taskType)205 switch(pTask->taskType) 206 206 { 207 207 case TaskVFSExplorer::Update: 208 208 { 209 209 if (pVFSExplorer->m->storageType == VFSType_File) 210 rc = pVFSExplorer->i_updateFS( task.get());210 rc = pVFSExplorer->i_updateFS(pTask); 211 211 else if (pVFSExplorer->m->storageType == VFSType_S3) 212 212 rc = VERR_NOT_IMPLEMENTED; … … 216 216 { 217 217 if (pVFSExplorer->m->storageType == VFSType_File) 218 rc = pVFSExplorer->i_deleteFS( task.get());218 rc = pVFSExplorer->i_deleteFS(pTask); 219 219 else if (pVFSExplorer->m->storageType == VFSType_S3) 220 220 rc = VERR_NOT_IMPLEMENTED; … … 222 222 } 223 223 default: 224 AssertMsgFailed(("Invalid task type %u specified!\n", task->taskType));224 AssertMsgFailed(("Invalid task type %u specified!\n", pTask->taskType)); 225 225 break; 226 226 } … … 409 409 410 410 /* Initialize our worker task */ 411 std::auto_ptr<TaskVFSExplorer> task(new TaskVFSExplorer(TaskVFSExplorer::Update, this, progress)); 412 413 rc = task->startThread(); 414 if (FAILED(rc)) throw rc; 415 416 /* Don't destruct on success */ 417 task.release(); 411 TaskVFSExplorer* pTask = new TaskVFSExplorer(TaskVFSExplorer::Update, this, progress); 412 413 //this function delete task in case of exceptions, so there is no need in the call of delete operator 414 rc = pTask->createThread(NULL, RTTHREADTYPE_MAIN_HEAVY_WORKER); 418 415 } 419 416 catch (HRESULT aRC) … … 526 523 527 524 /* Initialize our worker task */ 528 std::auto_ptr<TaskVFSExplorer> task(new TaskVFSExplorer(TaskVFSExplorer::Delete, this, progress));525 TaskVFSExplorer* pTask = new TaskVFSExplorer(TaskVFSExplorer::Delete, this, progress); 529 526 530 527 /* Add all filenames to delete as task data */ 531 528 for (size_t i = 0; i < aNames.size(); ++i) 532 task->filenames.push_back(aNames[i]); 533 534 rc = task->startThread(); 535 if (FAILED(rc)) throw rc; 536 537 /* Don't destruct on success */ 538 task.release(); 529 pTask->filenames.push_back(aNames[i]); 530 531 //this function delete task in case of exceptions, so there is no need in the call of delete operator 532 rc = pTask->createThread(NULL, RTTHREADTYPE_MAIN_HEAVY_WORKER); 539 533 } 540 534 catch (HRESULT aRC)
Note:
See TracChangeset
for help on using the changeset viewer.