third_party/virtualbox/src/VBox/Runtime/common/misc/thread.cpp
/**
 * Adopts the calling thread.
 * No locks are taken or released by this function.
 */
Adopts the calling thread.
No locks are taken or released by this function.
Adopts the calling thread . No locks are taken or released by this function .
static int rtThreadAdopt(RTTHREADTYPE enmType, unsigned fFlags, uint32_t fIntFlags, const char *pszName)
{
    int rc;
    PRTTHREADINT pThread;
    Assert(!(fFlags & RTTHREADFLAGS_WAITABLE));
    fFlags &= ~RTTHREADFLAGS_WAITABLE;
    rc = VERR_NO_MEMORY;
    pThread = rtThreadAlloc(enmType, fFlags, RTTHREADINT_FLAGS_ALIEN | fIntFlags, pszName);
    if (pThread)
    {
        RTNATIVETHREAD NativeThread = RTThreadNativeSelf();
        rc = rtThreadNativeAdopt(pThread);
        if (RT_SUCCESS(rc))
        {
            rtThreadInsert(pThread, NativeThread);
            rtThreadSetState(pThread, RTTHREADSTATE_RUNNING);
            rtThreadRelease(pThread);
        }
        else
            rtThreadDestroy(pThread);
    }
    return rc;
}
static int rtThreadAdopt ( RTTHREADTYPE enmType , unsigned fFlags , uint32_t fIntFlags , const char * pszName ) { int rc ; PRTTHREADINT pThread ; Assert ( ! ( fFlags & RTTHREADFLAGS_WAITABLE ) ) ; fFlags &= ~ RTTHREADFLAGS_WAITABLE ; rc = VERR_NO_MEMORY ; pThread = rtThreadAlloc ( enmType , fFlags , RTTHREADINT_FLAGS_ALIEN | fIntFlags , pszName ) ; if ( pThread ) { RTNATIVETHREAD NativeThread = RTThreadNativeSelf ( ) ; rc = rtThreadNativeAdopt ( pThread ) ; if ( RT_SUCCESS ( rc ) ) { rtThreadInsert ( pThread , NativeThread ) ; rtThreadSetState ( pThread , RTTHREADSTATE_RUNNING ) ; rtThreadRelease ( pThread ) ; } else rtThreadDestroy ( pThread ) ; } return rc ; }
Adopts the calling thread.
Adopts the calling thread .
/*
     * Allocate and insert the thread.
     * (It is vital that rtThreadNativeAdopt updates the TLS before
     * we try inserting the thread because of locking.)
     */