VirtualBox

Changeset 63181 in vbox for trunk/src/VBox/Main/src-all


Ignore:
Timestamp:
Aug 8, 2016 3:56:30 PM (8 years ago)
Author:
vboxsync
Message:

Main: warnings/cleanup

Location:
trunk/src/VBox/Main/src-all
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-all/ExtPackManagerImpl.cpp

    r63148 r63181  
    660660            {
    661661                ComPtr<Progress> ptrProgress = pTask->ptrProgress;
    662                 hrc = pTask->createThread(NULL, RTTHREADTYPE_DEFAULT);
     662                hrc = pTask->createThread(NULL /*phThread*/, RTTHREADTYPE_DEFAULT);
    663663                pTask = NULL; /* The _completely_ _undocumented_ createThread method always consumes pTask. */
    664664                if (SUCCEEDED(hrc))
  • trunk/src/VBox/Main/src-all/ThreadTask.cpp

    r60999 r63181  
    2121
    2222/**
    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.
    2824 *
    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.
    3128 *
    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:
    4330 *
    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
    5054 */
    51 HRESULT ThreadTask::createThread(PRTTHREAD pThread, RTTHREADTYPE enmType)
     55HRESULT ThreadTask::createThread(PRTTHREAD pThread /*= NULL*/, RTTHREADTYPE enmType /*= RTTHREADTYPE_MAIN_WORKER*/)
    5256{
    53     HRESULT rc = S_OK;
    54 
    5557    m_pThread = pThread;
    5658    int vrc = RTThreadCreate(m_pThread,
    57                              taskHandler,
     59                             taskHandlerThreadProc,
    5860                             (void *)this,
    5961                             0,
     
    6163                             0,
    6264                             this->getTaskName().c_str());
     65    if (RT_SUCCESS(vrc))
     66        return S_OK;
    6367
    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;
    7170}
    7271
     
    7574 * thread started for a Task.
    7675 */
    77 /* static */ DECLCALLBACK(int) ThreadTask::taskHandler(RTTHREAD /* thread */, void *pvUser)
     76/* static */ DECLCALLBACK(int) ThreadTask::taskHandlerThreadProc(RTTHREAD /* thread */, void *pvUser)
    7877{
    7978    if (pvUser == NULL)
    80         return VERR_INVALID_POINTER;
     79        return VERR_INVALID_POINTER; /* nobody cares */
    8180
    8281    ThreadTask *pTask = static_cast<ThreadTask *>(pvUser);
     
    8887
    8988    delete pTask;
    90 
    9189    return VINF_SUCCESS;
    9290}
     91
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette