本文整理汇总了C++中OperationContext::checkForInterrupt方法的典型用法代码示例。如果您正苦于以下问题:C++ OperationContext::checkForInterrupt方法的具体用法?C++ OperationContext::checkForInterrupt怎么用?C++ OperationContext::checkForInterrupt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OperationContext
的用法示例。
在下文中一共展示了OperationContext::checkForInterrupt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: yield
bool PlanYieldPolicy::yield(RecordFetcher* fetcher) {
invariant(_planYielding);
OperationContext* opCtx = _planYielding->getOpCtx();
invariant(opCtx);
// All YIELD_AUTO plans will get here eventually when the elapsed tracker triggers that it's
// time to yield. Whether or not we will actually yield (doc-level locking systems won't),
// we need to check if this operation has been interrupted. Throws if the interrupt flag is
// set.
opCtx->checkForInterrupt();
if (supportsDocLocking()) {
// Doc-level locking is supported, so no need to release locks.
return true;
}
// No need to yield if the collection is NULL.
if (NULL == _planYielding->collection()) {
return true;
}
_planYielding->saveState();
// Release and reacquire locks.
QueryYield::yieldAllLocks(opCtx, fetcher);
_elapsedTracker.resetLastTime();
return _planYielding->restoreState(opCtx);
}
示例2: yield
bool PlanYieldPolicy::yield(RecordFetcher* fetcher) {
invariant(_planYielding);
invariant(allowedToYield());
_forceYield = false;
OperationContext* opCtx = _planYielding->getOpCtx();
invariant(opCtx);
invariant(!opCtx->lockState()->inAWriteUnitOfWork());
// Can't use MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN/END since we need to call saveState
// before reseting the transaction.
for (int attempt = 1; true; attempt++) {
try {
// All YIELD_AUTO plans will get here eventually when the elapsed tracker triggers
// that it's time to yield. Whether or not we will actually yield, we need to check
// if this operation has been interrupted. Throws if the interrupt flag is set.
if (_policy == PlanExecutor::YIELD_AUTO) {
opCtx->checkForInterrupt();
}
// No need to yield if the collection is NULL.
if (NULL == _planYielding->collection()) {
return true;
}
try {
_planYielding->saveState();
}
catch (const WriteConflictException& wce) {
invariant(!"WriteConflictException not allowed in saveState");
}
if (_policy == PlanExecutor::WRITE_CONFLICT_RETRY_ONLY) {
// Just reset the snapshot. Leave all LockManager locks alone.
opCtx->recoveryUnit()->commitAndRestart();
}
else {
// Release and reacquire locks.
QueryYield::yieldAllLocks(opCtx, fetcher);
}
return _planYielding->restoreStateWithoutRetrying(opCtx);
}
catch (const WriteConflictException& wce) {
opCtx->getCurOp()->debug().writeConflicts++;
WriteConflictException::logAndBackoff(attempt,
"plan execution restoreState",
_planYielding->collection()->ns().ns());
// retry
}
}
}
示例3: yield
bool PlanYieldPolicy::yield(stdx::function<void()> beforeYieldingFn,
stdx::function<void()> whileYieldingFn) {
invariant(_planYielding);
invariant(canAutoYield());
// After we finish yielding (or in any early return), call resetTimer() to prevent yielding
// again right away. We delay the resetTimer() call so that the clock doesn't start ticking
// until after we return from the yield.
ON_BLOCK_EXIT([this]() { resetTimer(); });
_forceYield = false;
OperationContext* opCtx = _planYielding->getOpCtx();
invariant(opCtx);
invariant(!opCtx->lockState()->inAWriteUnitOfWork());
// Can't use writeConflictRetry since we need to call saveState before reseting the transaction.
for (int attempt = 1; true; attempt++) {
try {
// All YIELD_AUTO plans will get here eventually when the elapsed tracker triggers
// that it's time to yield. Whether or not we will actually yield, we need to check
// if this operation has been interrupted. Throws if the interrupt flag is set.
if (_policy == PlanExecutor::YIELD_AUTO) {
opCtx->checkForInterrupt();
}
try {
_planYielding->saveState();
} catch (const WriteConflictException&) {
invariant(!"WriteConflictException not allowed in saveState");
}
if (_policy == PlanExecutor::WRITE_CONFLICT_RETRY_ONLY) {
// Just reset the snapshot. Leave all LockManager locks alone.
opCtx->recoveryUnit()->abandonSnapshot();
} else {
// Release and reacquire locks.
if (beforeYieldingFn)
beforeYieldingFn();
QueryYield::yieldAllLocks(opCtx, whileYieldingFn, _planYielding->nss());
}
return _planYielding->restoreStateWithoutRetrying();
} catch (const WriteConflictException&) {
CurOp::get(opCtx)->debug().writeConflicts++;
WriteConflictException::logAndBackoff(
attempt, "plan execution restoreState", _planYielding->nss().ns());
// retry
}
}
}
示例4: yield
bool PlanYieldPolicy::yield(RecordFetcher* fetcher) {
invariant(_planYielding);
OperationContext* opCtx = _planYielding->getOpCtx();
invariant(opCtx);
// All YIELD_AUTO plans will get here eventually when the elapsed tracker triggers that
// it's time to yield. Whether or not we will actually yield, we need to check if this
// operation has been interrupted. Throws if the interrupt flag is set.
opCtx->checkForInterrupt();
// No need to yield if the collection is NULL.
if (NULL == _planYielding->collection()) {
return true;
}
_planYielding->saveState();
// Release and reacquire locks.
QueryYield::yieldAllLocks(opCtx, fetcher);
return _planYielding->restoreState(opCtx);
}