本文整理汇总了C++中WorkItem::GetContext方法的典型用法代码示例。如果您正苦于以下问题:C++ WorkItem::GetContext方法的具体用法?C++ WorkItem::GetContext怎么用?C++ WorkItem::GetContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkItem
的用法示例。
在下文中一共展示了WorkItem::GetContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Dispatch
//.........这里部分代码省略.........
{
pContext = m_pBoundVProc->m_pCriticalContext;
m_pBoundVProc->m_fCriticalIsReady = FALSE;
m_pBoundVProc->m_pCriticalContext = NULL;
#if defined(_DEBUG)
fromBits = CTX_DEBUGBIT_PRIMARYAFFINITIZEFROMCRITICAL;
#endif // _DEBUG
CONCRT_COREASSERT(pContext != NULL);
}
}
else
{
CONCRT_COREASSERT(!m_pBoundVProc->m_fCriticalIsReady);
}
//
// Next priority is searching for contexts to run.
//
if (pContext == NULL)
{
//
// We need to do a full search for runnables. This means all scheduling rings, nodes, LRCs, etc... The reason for this is subtle. Normally,
// if we can't quickly find something to run, we switch to the reserved context which is a real search context and everyone is happy (we keep the virtual
// processor active). The only time we'll put the virtual processor to sleep HERE is when there's a critical context blocked or there are no reserved
// contexts.
// You might think we're okay to do that because the wakings there explicitly notify us. Unfortunately, those special contexts might be blocked
// on a lock held by an ARBITRARY context. That ARBITRARY context might have been moved to a runnables list in a different scheduling ring/node by
// the MoveCompletionListToRunnables above. Therefore, we must do a FULL search for runnables here across all rings.
//
WorkItem work;
if (m_pBoundVProc->SearchForWork(&work, pSegment, false, WorkItem::WorkItemTypeContext))
{
pContext = work.GetContext();
#if defined(_DEBUG)
CMTRACE(MTRACE_EVT_SFW_FOUNDBY, pContext, m_pBoundVProc, NULL);
fromBits = CTX_DEBUGBIT_PRIMARYAFFINITIZEFROMSEARCH;
#endif // _DEBUG
}
}
//
// If we could not find anyone to run by this point, we're stuck having to create a new SFW context. This should only happen
// if we're **NOT** critically blocked.
//
if (!fCritical && pContext == NULL)
{
pContext = m_pScheduler->GetReservedContext();
if (pContext == NULL)
m_pScheduler->DeferredGetInternalContext();
else
pContext->PrepareForUse(m_pScheduler->GetAnonymousScheduleGroupSegment(), NULL, false);
#if defined(_DEBUG)
fromBits = CTX_DEBUGBIT_PRIMARYRESERVEDCONTEXT;
#endif // _DEBUG
}
if (pPreviousContext != NULL)
{
//
// After one time through the search loop from the source, let go of the previous context. This means we can no longer originate
// a search from the source group. We cannot place a reference here because removing it might entail a deletion from the ListArray
// which cannot happen on the primary. Just search outward from the anonymous schedule group if we cannot find anything the first time