Changeset 63181 in vbox for trunk/src/VBox/Main/src-all
- Timestamp:
- Aug 8, 2016 3:56:30 PM (8 years ago)
- Location:
- trunk/src/VBox/Main/src-all
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-all/ExtPackManagerImpl.cpp
r63148 r63181 660 660 { 661 661 ComPtr<Progress> ptrProgress = pTask->ptrProgress; 662 hrc = pTask->createThread(NULL , RTTHREADTYPE_DEFAULT);662 hrc = pTask->createThread(NULL /*phThread*/, RTTHREADTYPE_DEFAULT); 663 663 pTask = NULL; /* The _completely_ _undocumented_ createThread method always consumes pTask. */ 664 664 if (SUCCEEDED(hrc)) -
trunk/src/VBox/Main/src-all/ThreadTask.cpp
r60999 r63181 21 21 22 22 /** 23 * The function takes ownership of "this" instance (object 24 * instance which calls this function). 25 * And the function is responsible for deletion of "this" 26 * pointer in all cases. 27 * Possible way of usage: 23 * Starts the task (on separate thread), consuming @a this. 28 24 * 29 * int vrc = VINF_SUCCESS; 30 * HRESULT hr = S_OK; 25 * The function takes ownership of "this" instance (object instance which calls 26 * this function). And the function is responsible for deletion of "this" 27 * pointer in all cases. 31 28 * 32 * SomeTaskInheritedFromThreadTask* pTask = NULL; 33 * try 34 * { 35 * pTask = new SomeTaskInheritedFromThreadTask(this); 36 * if (!pTask->Init())//some init procedure 37 * { 38 * delete pTask; 39 * throw E_FAIL; 40 * } 41 * //this function delete pTask in case of exceptions, so 42 * there is no need the call of delete operator 29 * Possible way of usage: 43 30 * 44 * hr = pTask->createThread(); 45 * } 46 * catch(...) 47 * { 48 * vrc = E_FAIL; 49 * } 31 * @code{.cpp} 32 * int vrc = VINF_SUCCESS; 33 * HRESULT hr = S_OK; 34 * 35 * SomeTaskInheritedFromThreadTask* pTask = NULL; 36 * try 37 * { 38 * pTask = new SomeTaskInheritedFromThreadTask(this); 39 * if (!pTask->Init())//some init procedure 40 * { 41 * delete pTask; 42 * throw E_FAIL; 43 * } 44 * //this function delete pTask in case of exceptions, so 45 * there is no need the call of delete operator 46 * 47 * hr = pTask->createThread(); 48 * } 49 * catch(...) 50 * { 51 * vrc = E_FAIL; 52 * } 53 * @endcode 50 54 */ 51 HRESULT ThreadTask::createThread(PRTTHREAD pThread , RTTHREADTYPE enmType)55 HRESULT ThreadTask::createThread(PRTTHREAD pThread /*= NULL*/, RTTHREADTYPE enmType /*= RTTHREADTYPE_MAIN_WORKER*/) 52 56 { 53 HRESULT rc = S_OK;54 55 57 m_pThread = pThread; 56 58 int vrc = RTThreadCreate(m_pThread, 57 taskHandler ,59 taskHandlerThreadProc, 58 60 (void *)this, 59 61 0, … … 61 63 0, 62 64 this->getTaskName().c_str()); 65 if (RT_SUCCESS(vrc)) 66 return S_OK; 63 67 64 if (RT_FAILURE(vrc)) 65 { 66 delete this; 67 return E_FAIL; 68 } 69 70 return rc; 68 delete this; 69 return E_FAIL; 71 70 } 72 71 … … 75 74 * thread started for a Task. 76 75 */ 77 /* static */ DECLCALLBACK(int) ThreadTask::taskHandler (RTTHREAD /* thread */, void *pvUser)76 /* static */ DECLCALLBACK(int) ThreadTask::taskHandlerThreadProc(RTTHREAD /* thread */, void *pvUser) 78 77 { 79 78 if (pvUser == NULL) 80 return VERR_INVALID_POINTER; 79 return VERR_INVALID_POINTER; /* nobody cares */ 81 80 82 81 ThreadTask *pTask = static_cast<ThreadTask *>(pvUser); … … 88 87 89 88 delete pTask; 90 91 89 return VINF_SUCCESS; 92 90 } 91
Note:
See TracChangeset
for help on using the changeset viewer.