Changeset 64975 in vbox
- Timestamp:
- Dec 21, 2016 12:24:25 PM (8 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ThreadTask.h
r64973 r64975 36 36 ThreadTask(const Utf8Str &t) 37 37 : m_strTaskName(t) 38 , mAsync( false)38 , mAsync(true) 39 39 { } 40 40 … … 44 44 HRESULT createThread(void); 45 45 HRESULT createThreadWithType(RTTHREADTYPE enmType); 46 HRESULT createThreadWithRaceCondition(PRTTHREAD pThread);47 46 48 47 inline Utf8Str getTaskName() const { return m_strTaskName; } … … 50 49 51 50 protected: 52 HRESULT createThreadInternal(RTTHREADTYPE enmType , PRTTHREAD pThread);51 HRESULT createThreadInternal(RTTHREADTYPE enmType); 53 52 static DECLCALLBACK(int) taskHandlerThreadProc(RTTHREAD thread, void *pvUser); 54 53 -
trunk/src/VBox/Main/src-all/ThreadTask.cpp
r64972 r64975 47 47 @endcode 48 48 * 49 * @sa createThreadWithType , createThreadWithRaceCondition49 * @sa createThreadWithType 50 50 */ 51 51 HRESULT ThreadTask::createThread(void) 52 52 { 53 return createThreadInternal(RTTHREADTYPE_MAIN_WORKER , NULL /*phThread*/);53 return createThreadInternal(RTTHREADTYPE_MAIN_WORKER); 54 54 } 55 55 … … 62 62 HRESULT ThreadTask::createThreadWithType(RTTHREADTYPE enmType) 63 63 { 64 return createThreadInternal(enmType, NULL /*phThread*/); 65 } 66 67 68 /** 69 * Same ThreadTask::createThread(), except it returns a thread handle. 70 * 71 * If the task thread is incorrectly mananged, the caller may easily race the 72 * completion and termination of the task thread! Use with care! 73 * 74 * @param phThread Handle of the worker thread. 75 */ 76 HRESULT ThreadTask::createThreadWithRaceCondition(PRTTHREAD phThread) 77 { 78 return createThreadInternal(RTTHREADTYPE_MAIN_WORKER, phThread); 64 return createThreadInternal(enmType); 79 65 } 80 66 … … 82 68 /** 83 69 * Internal worker for ThreadTask::createThread, 84 * ThreadTask::createThreadWithType , ThreadTask::createThreadwithRaceCondition.70 * ThreadTask::createThreadWithType. 85 71 * 86 72 * @note Always consumes @a this! 87 73 */ 88 HRESULT ThreadTask::createThreadInternal(RTTHREADTYPE enmType , PRTTHREAD phThread)74 HRESULT ThreadTask::createThreadInternal(RTTHREADTYPE enmType) 89 75 { 90 RTTHREAD hThread; 91 int vrc = RTThreadCreate(&hThread, 76 int vrc = RTThreadCreate(NULL, 92 77 taskHandlerThreadProc, 93 78 (void *)this, … … 97 82 this->getTaskName().c_str()); 98 83 if (RT_SUCCESS(vrc)) 99 {100 mAsync = true;101 if (phThread)102 *phThread = hThread;103 84 return S_OK; 104 }105 85 86 mAsync = false; 106 87 delete this; 107 88 return E_FAIL;
Note:
See TracChangeset
for help on using the changeset viewer.