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


C++ Thread::ClearDoNotTriggerGc方法代码示例

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


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

示例1: InvokeGcCallouts

// Invoke all the registered GC callouts of the given kind. The condemned generation of the current collection
// is passed along to the callouts.
void RestrictedCallouts::InvokeGcCallouts(GcRestrictedCalloutKind eKind, UInt32 uiCondemnedGeneration)
{
    ASSERT(eKind < GCRC_Count);

    // It is illegal for any of the callouts to trigger a GC.
    Thread * pThread = ThreadStore::GetCurrentThread();
    pThread->SetDoNotTriggerGc();

    // Due to the above we have better suppress GC stress.
    bool fGcStressWasSuppressed = pThread->IsSuppressGcStressSet();
    if (!fGcStressWasSuppressed)
        pThread->SetSuppressGcStress();

    GcRestrictedCallout * pCurrCallout = s_rgGcRestrictedCallouts[eKind];
    while (pCurrCallout)
    {
        // Make the callout.
        ((GcRestrictedCallbackFunction)pCurrCallout->m_pCalloutMethod)(uiCondemnedGeneration);

        pCurrCallout = pCurrCallout->m_pNext;
    }

    // Revert GC stress mode if we changed it.
    if (!fGcStressWasSuppressed)
        pThread->ClearSuppressGcStress();

    pThread->ClearDoNotTriggerGc();
}
开发者ID:huamichaelchen,项目名称:corert,代码行数:30,代码来源:RestrictedCallouts.cpp

示例2: InvokeRefCountedHandleCallbacks

// Invoke all the registered ref counted handle callouts for the given object extracted from the handle. The
// result is the union of the results for all the handlers that matched the object type (i.e. if one of them
// returned true the overall result is true otherwise false is returned (which includes the case where no
// handlers matched)). Since there should be no other side-effects of the callout, the invocations cease as
// soon as a handler returns true.
bool RestrictedCallouts::InvokeRefCountedHandleCallbacks(Object * pObject)
{
    bool fResult = false;

    // It is illegal for any of the callouts to trigger a GC.
    Thread * pThread = ThreadStore::GetCurrentThread();
    pThread->SetDoNotTriggerGc();

    // Due to the above we have better suppress GC stress.
    bool fGcStressWasSuppressed = pThread->IsSuppressGcStressSet();
    if (!fGcStressWasSuppressed)
        pThread->SetSuppressGcStress();

    HandleTableRestrictedCallout * pCurrCallout = s_pHandleTableRestrictedCallouts;
    while (pCurrCallout)
    {
        if (pObject->get_SafeEEType() == pCurrCallout->m_pTypeFilter)
        {
            // Make the callout. Return true to our caller as soon as we see a true result here.
            if (((HandleTableRestrictedCallbackFunction)pCurrCallout->m_pCalloutMethod)(pObject))
            {
                fResult = true;
                goto Done;
            }
        }

        pCurrCallout = pCurrCallout->m_pNext;
    }

  Done:
    // Revert GC stress mode if we changed it.
    if (!fGcStressWasSuppressed)
        pThread->ClearSuppressGcStress();

    pThread->ClearDoNotTriggerGc();

    return fResult;
}
开发者ID:huamichaelchen,项目名称:corert,代码行数:43,代码来源:RestrictedCallouts.cpp


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