VirtualBox

Changeset 63186 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 8, 2016 5:39:16 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
109805
Message:

ThreadTask: Cleaning up handler() methods.

Location:
trunk/src/VBox/Main
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestProcessImpl.h

    r63153 r63186  
    2626class Console;
    2727class GuestSession;
     28class GuestProcessStartTask;
    2829
    2930/**
     
    8687    int i_prepareExecuteEnv(const char *pszEnv, void **ppvList, ULONG *pcbList, ULONG *pcEnvVars);
    8788    int i_setProcessStatus(ProcessStatus_T procStatus, int procRc);
    88     static DECLCALLBACK(int) i_startProcessThread(RTTHREAD Thread, void *pvUser);
     89    static void i_startProcessThreadTask(GuestProcessStartTask *pTask);
    8990    /** @}  */
    9091
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r62485 r63186  
    3232
    3333class Guest;
     34class GuestSessionTaskInternalOpen;
    3435
    3536/**
     
    4849
    4950    virtual int Run(void) = 0;
    50     virtual int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress) = 0;
     51    void handler()
     52    {
     53        int vrc = Run();
     54        NOREF(vrc);
     55        /** @todo
     56         *
     57         * r=bird: what was your idea WRT to Run status code and async tasks?
     58         *
     59         */
     60    }
     61
     62    int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress);
    5163
    5264    HRESULT Init(const Utf8Str &strTaskDesc)
     
    92104                    uint32_t uFlags,
    93105                    uint32_t uTimeoutMS);
    94 
    95106    virtual ~SessionTaskOpen(void);
    96 
    97 public:
    98 
    99     int Run(int *pGuestRc);
    100     int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress);
    101     static DECLCALLBACK(int) taskThread(RTTHREAD Thread, void *pvUser);
    102     void handler()
    103     {
    104         int vrc = SessionTaskOpen::taskThread(NULL, this);
    105     }
     107    int Run(void);
    106108
    107109protected:
     
    122124    SessionTaskCopyTo(GuestSession *pSession,
    123125                      const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags);
    124 
    125126    SessionTaskCopyTo(GuestSession *pSession,
    126127                      PRTFILE pSourceFile, size_t cbSourceOffset, uint64_t cbSourceSize,
    127128                      const Utf8Str &strDest, uint32_t uFlags);
    128 
    129129    virtual ~SessionTaskCopyTo(void);
    130 
    131 public:
    132 
    133130    int Run(void);
    134     int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress);
    135     static DECLCALLBACK(int) taskThread(RTTHREAD Thread, void *pvUser);
    136     void handler()
    137     {
    138         int vrc = SessionTaskCopyTo::taskThread(NULL, this);
    139     }
    140131
    141132protected:
     
    158149    SessionTaskCopyFrom(GuestSession *pSession,
    159150                        const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags);
    160 
    161151    virtual ~SessionTaskCopyFrom(void);
    162 
    163 public:
    164 
    165152    int Run(void);
    166     int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress);
    167     static DECLCALLBACK(int) taskThread(RTTHREAD Thread, void *pvUser);
    168     void handler()
    169     {
    170         int vrc = SessionTaskCopyFrom::taskThread(NULL, this);
    171     }
    172153
    173154protected:
     
    188169                               const Utf8Str &strSource, const ProcessArguments &aArguments,
    189170                               uint32_t uFlags);
    190 
    191171    virtual ~SessionTaskUpdateAdditions(void);
    192 
    193 public:
    194 
    195172    int Run(void);
    196     int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress);
    197     static DECLCALLBACK(int) taskThread(RTTHREAD Thread, void *pvUser);
    198     void handler()
    199     {
    200         int vrc = SessionTaskUpdateAdditions::taskThread(NULL, this);
    201     }
    202173
    203174protected:
     
    484455    int                     i_startSessionInternal(int *pGuestRc);
    485456    int                     i_startSessionAsync(void);
    486     static DECLCALLBACK(int)
    487                             i_startSessionThread(RTTHREAD Thread, void *pvUser);
     457    static void             i_startSessionThreadTask(GuestSessionTaskInternalOpen *pTask);
    488458    Guest                  *i_getParent(void) { return mParent; }
    489459    uint32_t                i_getProtocolVersion(void) { return mData.mProtocolVersion; }
  • trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp

    r63178 r63186  
    9393    void handler()
    9494    {
    95         int vrc = GuestProcess::i_startProcessThread(NULL, this);
     95        GuestProcess::i_startProcessThreadTask(this);
    9696    }
    9797};
     
    11891189
    11901190/* static */
    1191 DECLCALLBACK(int) GuestProcess::i_startProcessThread(RTTHREAD Thread, void *pvUser)
    1192 {
    1193     LogFlowFunc(("pvUser=%p\n", pvUser));
    1194 
    1195     GuestProcessStartTask* pTask = static_cast<GuestProcessStartTask*>(pvUser);
     1191void GuestProcess::i_startProcessThreadTask(GuestProcessStartTask *pTask)
     1192{
     1193    LogFlowFunc(("pTask=%p\n", pTask));
    11961194
    11971195    const ComObjPtr<GuestProcess> pProcess(pTask->i_process());
     
    11991197
    12001198    AutoCaller autoCaller(pProcess);
    1201     if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1199    if (FAILED(autoCaller.rc()))
     1200        return;
    12021201
    12031202    int vrc = pProcess->i_startProcess(30 * 1000 /* 30s timeout */,
    12041203                                       NULL /* Guest rc, ignored */);
     1204/** @todo
     1205 *
     1206 * r=bird: what's up with vrc here? Safe to ignore it?
     1207 *
     1208 */
     1209
    12051210    /* Nothing to do here anymore. */
    12061211
    1207     LogFlowFunc(("pProcess=%p returning rc=%Rrc\n", (GuestProcess *)pProcess, vrc));
    1208     return vrc;
     1212    LogFlowFunc(("pProcess=%p vrc=%Rrc (ignored)\n", (GuestProcess *)pProcess, vrc));
     1213    NOREF(vrc);
    12091214}
    12101215
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r63182 r63186  
    9292    void handler()
    9393    {
    94         int vrc = GuestSession::i_startSessionThread(NULL, this);
     94        GuestSession::i_startSessionThreadTask(this);
    9595    }
    9696};
     
    17671767
    17681768/* static */
    1769 DECLCALLBACK(int) GuestSession::i_startSessionThread(RTTHREAD Thread, void *pvUser)
    1770 {
    1771     LogFlowFunc(("pvUser=%p\n", pvUser));
    1772 
    1773 
    1774     GuestSessionTaskInternalOpen* pTask = static_cast<GuestSessionTaskInternalOpen*>(pvUser);
     1769void GuestSession::i_startSessionThreadTask(GuestSessionTaskInternalOpen *pTask)
     1770{
     1771    LogFlowFunc(("pTask=%p\n", pTask));
    17751772    AssertPtr(pTask);
    17761773
     
    17791776
    17801777    AutoCaller autoCaller(pSession);
    1781     if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1778    if (FAILED(autoCaller.rc()))
     1779        return;
    17821780
    17831781    int vrc = pSession->i_startSessionInternal(NULL /* Guest rc, ignored */);
     1782/** @todo
     1783 *
     1784 * r=bird: Is it okay to ignore @a vrc here?
     1785 *
     1786 */
     1787
    17841788    /* Nothing to do here anymore. */
    17851789
    17861790    LogFlowFuncLeaveRC(vrc);
    1787     return vrc;
     1791    NOREF(vrc);
    17881792}
    17891793
  • trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp

    r63182 r63186  
    6767/////////////////////////////////////////////////////////////////////////////
    6868
    69 GuestSessionTask::GuestSessionTask(GuestSession *pSession):ThreadTask("GenericGuestSessionTask")
     69GuestSessionTask::GuestSessionTask(GuestSession *pSession)
     70    : ThreadTask("GenericGuestSessionTask")
    7071{
    7172    mSession = pSession;
     
    99100    return hr;
    100101}
     102
     103int GuestSessionTask::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
     104{
     105    LogFlowThisFunc(("strDesc=%s\n", strDesc.c_str()));
     106
     107    mDesc = strDesc;
     108    mProgress = pProgress;
     109    HRESULT hrc = createThreadWithType(RTTHREADTYPE_MAIN_HEAVY_WORKER);
     110
     111    LogFlowThisFunc(("Returning hrc=%Rhrc\n", hrc));
     112    return Global::vboxStatusCodeToCOM(hrc);
     113}
     114
    101115
    102116int GuestSessionTask::getGuestProperty(const ComObjPtr<Guest> &pGuest,
     
    203217}
    204218
    205 int SessionTaskOpen::Run(int *pGuestRc)
     219int SessionTaskOpen::Run(void)
    206220{
    207221    LogFlowThisFuncEnter();
     
    213227    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    214228
    215     int vrc = pSession->i_startSessionInternal(pGuestRc);
     229    int vrc = pSession->i_startSessionInternal(NULL /*pvrcGuest*/);
    216230    /* Nothing to do here anymore. */
    217231
    218232    LogFlowFuncLeaveRC(vrc);
    219233    return vrc;
    220 }
    221 
    222 int SessionTaskOpen::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
    223 {
    224     LogFlowThisFunc(("strDesc=%s\n", strDesc.c_str()));
    225 
    226     mDesc = strDesc;
    227     mProgress = pProgress;
    228 
    229     int rc = RTThreadCreate(NULL, SessionTaskOpen::taskThread, this,
    230                             0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,
    231                             "gctlSesOpen");
    232     LogFlowFuncLeaveRC(rc);
    233     return rc;
    234 }
    235 
    236 /* static */
    237 DECLCALLBACK(int) SessionTaskOpen::taskThread(RTTHREAD Thread, void *pvUser)
    238 {
    239     SessionTaskOpen* task = static_cast<SessionTaskOpen*>(pvUser);
    240     AssertReturn(task, VERR_GENERAL_FAILURE);
    241 
    242     LogFlowFunc(("pTask=%p\n", task));
    243 
    244     return task->Run(NULL /* guestRc */);
    245234}
    246235
     
    615604    LogFlowFuncLeaveRC(rc);
    616605    return rc;
    617 }
    618 
    619 int SessionTaskCopyTo::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
    620 {
    621     LogFlowThisFunc(("strDesc=%s, strSource=%s, strDest=%s, mCopyFileFlags=%x\n",
    622                      strDesc.c_str(), mSource.c_str(), mDest.c_str(), mCopyFileFlags));
    623 
    624     mDesc = strDesc;
    625     mProgress = pProgress;
    626 
    627     int rc = RTThreadCreate(NULL, SessionTaskCopyTo::taskThread, this,
    628                             0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,
    629                             "gctlCpyTo");
    630     LogFlowFuncLeaveRC(rc);
    631     return rc;
    632 }
    633 
    634 /* static */
    635 DECLCALLBACK(int) SessionTaskCopyTo::taskThread(RTTHREAD Thread, void *pvUser)
    636 {
    637     SessionTaskCopyTo* task = static_cast<SessionTaskCopyTo*>(pvUser);
    638     AssertReturn(task, VERR_GENERAL_FAILURE);
    639 
    640     LogFlowFunc(("pTask=%p\n", task));
    641 
    642     return task->Run();
    643606}
    644607
     
    920883    LogFlowFuncLeaveRC(rc);
    921884    return rc;
    922 }
    923 
    924 int SessionTaskCopyFrom::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
    925 {
    926     LogFlowThisFunc(("strDesc=%s, strSource=%s, strDest=%s, uFlags=%x\n",
    927                      strDesc.c_str(), mSource.c_str(), mDest.c_str(), mFlags));
    928 
    929     mDesc = strDesc;
    930     mProgress = pProgress;
    931 
    932     int rc = RTThreadCreate(NULL, SessionTaskCopyFrom::taskThread, this,
    933                             0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,
    934                             "gctlCpyFrom");
    935     LogFlowFuncLeaveRC(rc);
    936     return rc;
    937 }
    938 
    939 /* static */
    940 DECLCALLBACK(int) SessionTaskCopyFrom::taskThread(RTTHREAD Thread, void *pvUser)
    941 {
    942     SessionTaskCopyFrom* task = static_cast<SessionTaskCopyFrom*>(pvUser);
    943     AssertReturn(task, VERR_GENERAL_FAILURE);
    944 
    945     LogFlowFunc(("pTask=%p\n", task));
    946 
    947     return task->Run();
    948885}
    949886
     
    16591596}
    16601597
    1661 int SessionTaskUpdateAdditions::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
    1662 {
    1663     LogFlowThisFunc(("strDesc=%s, strSource=%s, uFlags=%x\n",
    1664                      strDesc.c_str(), mSource.c_str(), mFlags));
    1665 
    1666     mDesc = strDesc;
    1667     mProgress = pProgress;
    1668 
    1669     int rc = RTThreadCreate(NULL, SessionTaskUpdateAdditions::taskThread, this,
    1670                             0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,
    1671                             "gctlUpGA");
    1672     LogFlowFuncLeaveRC(rc);
    1673     return rc;
    1674 }
    1675 
    1676 /* static */
    1677 DECLCALLBACK(int) SessionTaskUpdateAdditions::taskThread(RTTHREAD Thread, void *pvUser)
    1678 {
    1679     SessionTaskUpdateAdditions* task = static_cast<SessionTaskUpdateAdditions*>(pvUser);
    1680     AssertReturn(task, VERR_GENERAL_FAILURE);
    1681 
    1682     LogFlowFunc(("pTask=%p\n", task));
    1683 
    1684     return task->Run();
    1685 }
    1686 
Note: See TracChangeset for help on using the changeset viewer.

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