当前位置: 首页>>代码示例>>C++>>正文


C++ CPalThread::ReleaseThreadReference方法代码示例

本文整理汇总了C++中CPalThread::ReleaseThreadReference方法的典型用法代码示例。如果您正苦于以下问题:C++ CPalThread::ReleaseThreadReference方法的具体用法?C++ CPalThread::ReleaseThreadReference怎么用?C++ CPalThread::ReleaseThreadReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CPalThread的用法示例。


在下文中一共展示了CPalThread::ReleaseThreadReference方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateThreadData

PAL_ERROR
AllocatePalThread(CPalThread **ppThread)
{
    CPalThread *pThread = NULL;

    PAL_ERROR palError = CreateThreadData(&pThread);
    if (NO_ERROR != palError)
    {
        goto exit;
    }

    HANDLE hThread;
    palError = CreateThreadObject(pThread, pThread, &hThread);
    if (NO_ERROR != palError)
    {
        pthread_setspecific(thObjKey, NULL);
        pThread->ReleaseThreadReference();
        goto exit;
    }
    
    // Like CreateInitialProcessAndThreadObjects, we do not need this 
    // thread handle, since we're not returning it to anyone who will 
    // possibly release it.
    (void)g_pObjectManager->RevokeHandle(pThread, hThread);

    PROCAddThread(pThread, pThread);

exit:
    *ppThread = pThread;
    return palError;
}
开发者ID:Afshintm,项目名称:coreclr,代码行数:31,代码来源:sxs.cpp

示例2: fail

/*++
Function:
  PAL_Enter

Abstract:
  This function needs to be called on a thread when it enters
  a region of code that depends on this instance of the PAL
  in the process, and the current thread may or may not be
  known to the PAL.  This function can fail (for something else
  than an internal error) if this is the first time that the
  current thread entered this PAL.  Note that PAL_Initialize
  implies a call to this function.

  NOTE: This function must not modify LastError.
--*/
PAL_ERROR
PALAPI
PAL_Enter(PAL_Boundary boundary)
{
    ENTRY_EXTERNAL("PAL_Enter(boundary=%u)\n", boundary);

    PAL_ERROR palError = ERROR_SUCCESS;
    CPalThread *pThread = InternalGetCurrentThread();
    if (pThread != NULL)
    {
        palError = pThread->Enter(boundary);
    }
    else
    {
        // If this assert fires, we'll have to pipe this information so that 
        // CPalThread's RunPostCreateInitializers call to SEHEnable 
        // can know what direction.
        _ASSERT_MSG(PAL_BoundaryTop == boundary, "How are we entering a PAL "
            "thread for the first time not from the top? (boundary=%u)", boundary);
            
        palError = CreateThreadData(&pThread);
        if (NO_ERROR != palError)
        {
            ERROR("Unable to create thread data: error %d\n", palError);
            goto EXIT;
        }

        HANDLE hThread;
        palError = CreateThreadObject(pThread, pThread, &hThread);
        if (NO_ERROR != palError)
        {
            ERROR("Unable to create thread object: error %d\n", palError);
            pthread_setspecific(thObjKey, NULL);
            pThread->ReleaseThreadReference();
            goto EXIT;
        }
        
        // Like CreateInitialProcessAndThreadObjects, we do not need this 
        // thread handle, since we're not returning it to anyone who will 
        // possibly release it.
        (void)g_pObjectManager->RevokeHandle(pThread, hThread);

        PROCAddThread(pThread, pThread);
    }

EXIT:
    LOGEXIT("PAL_Enter returns %d\n", palError);
    return palError;
}
开发者ID:Dykam,项目名称:coreclr,代码行数:64,代码来源:sxs.cpp

示例3: ERROR

PAL_ERROR
AllocatePalThread(CPalThread **ppThread)
{
    CPalThread *pThread = NULL;
    PAL_ERROR palError;

#if !HAVE_MACH_EXCEPTIONS
    // Ensure alternate stack for SIGSEGV handling. Our SIGSEGV handler is set to
    // run on an alternate stack and the stack needs to be allocated per thread.
    if (!EnsureSignalAlternateStack())
    {
        ERROR("Cannot allocate alternate stack for SIGSEGV handler!\n");
        palError = ERROR_NOT_ENOUGH_MEMORY;
        goto exit;
    }
#endif // !HAVE_MACH_EXCEPTIONS

    palError = CreateThreadData(&pThread);
    if (NO_ERROR != palError)
    {
        goto exit;
    }

    HANDLE hThread;
    palError = CreateThreadObject(pThread, pThread, &hThread);
    if (NO_ERROR != palError)
    {
        pthread_setspecific(thObjKey, NULL);
        pThread->ReleaseThreadReference();
        goto exit;
    }
    
    // Like CreateInitialProcessAndThreadObjects, we do not need this 
    // thread handle, since we're not returning it to anyone who will 
    // possibly release it.
    (void)g_pObjectManager->RevokeHandle(pThread, hThread);

    PROCAddThread(pThread, pThread);

exit:
    *ppThread = pThread;
    return palError;
}
开发者ID:DrewScoggins,项目名称:coreclr,代码行数:43,代码来源:sxs.cpp

示例4: InternalGetCurrentThread


//.........这里部分代码省略.........

            TRACE("About to suspend every other thread\n");

            /* prevent other threads from acquiring signaled objects */
            PROCCondemnOtherThreads();
            /* prevent other threads from using services we're shutting down */
            PROCSuspendOtherThreads();

            TRACE("Every other thread suspended until exit\n");
        }

        /* Fall down for PALCLEANUP_ALL_STEPS */
        if (PALCLEANUP_ALL_STEPS != step)
            break;

    case PALCLEANUP_STEP_TWO:
        if (!step_done[PALCLEANUP_STEP_TWO])
        {
            step_done[PALCLEANUP_STEP_TWO] = 1;

            /* LOADFreeeModules needs to be called before unitializing the rest
               of the PAL since it could result in calling DllMain for loaded
               libraries. For the user DllMain, all PAL APIs should still be
               functional. */
            LOADFreeModules(FALSE);

#ifdef PAL_PERF
            PERFDisableProcessProfile();
            PERFDisableThreadProfile(FALSE);
            PERFTerminate();  
#endif

            if (full_cleanup)
            {
                /* close primary handles of standard file objects */
                FILECleanupStdHandles();
                /* This unloads the palrt so, during its unloading, they
                   can call any number of APIs, so we have to be active for it to work. */
                FMTMSG_FormatMessageCleanUp();
                VIRTUALCleanup();
                /* SEH requires information from the process structure to work;
                   LOADFreeModules requires SEH to be functional when calling DllMain.
                   Therefore SEHCleanup must go between LOADFreeModules and
                   PROCCleanupInitialProcess */
                SEHCleanup();
                PROCCleanupInitialProcess();
            }

            // Object manager shutdown may cause all CPalThread objects
            // to be deleted. Since the CPalThread of the shutdown thread
            // needs to be available for reference by the thread suspension unsafe
            // operations, the reference of CPalThread is incremented here
            // to keep it alive until PAL finishes cleanup.
            pThread->AddThreadReference();

            //
            // Shutdown object manager -- this needs to happen before the
            // synch manager shutdown since it will call into the synch
            // manager to free object synch data
            // 
            static_cast<CSharedMemoryObjectManager*>(g_pObjectManager)->Shutdown(pThread);

            //
            // Final synch manager shutdown
            //
            CPalSynchMgrController::Shutdown(pThread, full_cleanup);

            if (full_cleanup)
            {
                /* It needs to be done after stopping the handle manager, because
                   the cleanup will delete the critical section which is used
                   when closing the handle of a file mapping */
                MAPCleanup();
                // MutexCleanup();

                MiscCleanup();

                TLSCleanup();
            }

            // The thread object will no longer be available after the shutdown thread
            // releases the thread reference.
            g_fThreadDataAvailable = FALSE;
            pThread->ReleaseThreadReference();
            pthread_setspecific(thObjKey, NULL); // Make sure any TLS entry is removed.

            // Since thread object is no longer available here,
            // the code path from here should stop using any functions
            // that reference thread object.
            SHMCleanup();

            TRACE("PAL Terminated.\n");
        }
        break;

    default:
        ASSERT("Unknown final cleanup step %d", step);
        break;
    }
}
开发者ID:Dreamxwang,项目名称:coreclr,代码行数:101,代码来源:pal.cpp


注:本文中的CPalThread::ReleaseThreadReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。