本文整理汇总了C++中OperationContext::waitForConditionOrInterrupt方法的典型用法代码示例。如果您正苦于以下问题:C++ OperationContext::waitForConditionOrInterrupt方法的具体用法?C++ OperationContext::waitForConditionOrInterrupt怎么用?C++ OperationContext::waitForConditionOrInterrupt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OperationContext
的用法示例。
在下文中一共展示了OperationContext::waitForConditionOrInterrupt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shutDown
void MobileSessionPool::shutDown() {
stdx::unique_lock<stdx::mutex> lk(_mutex);
_shuttingDown = true;
// Retrieve the operation context from the thread's client if the client exists.
if (haveClient()) {
OperationContext* opCtx = cc().getOperationContext();
// Locks if the operation context still exists.
if (opCtx) {
opCtx->waitForConditionOrInterrupt(
_releasedSessionNotifier, lk, [&] { return _sessions.size() == _curPoolSize; });
}
} else {
_releasedSessionNotifier.wait(lk, [&] { return _sessions.size() == _curPoolSize; });
}
// Retry all the drops that have been queued on failure.
// Create a new sqlite session to do so, all other sessions might have been closed already.
if (!failedDropsQueue.isEmpty()) {
sqlite3* session;
int status = sqlite3_open(_path.c_str(), &session);
embedded::checkStatus(status, SQLITE_OK, "sqlite3_open");
std::unique_ptr<MobileSession> mobSession = stdx::make_unique<MobileSession>(session, this);
LOG(MOBILE_LOG_LEVEL_LOW) << "MobileSE: Executing queued drops at shutdown";
failedDropsQueue.execAndDequeueAllOps(mobSession.get());
sqlite3_close(session);
}
for (auto&& session : _sessions) {
sqlite3_close(session);
}
}