本文整理汇总了C++中Stats::curr方法的典型用法代码示例。如果您正苦于以下问题:C++ Stats::curr方法的具体用法?C++ Stats::curr怎么用?C++ Stats::curr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stats
的用法示例。
在下文中一共展示了Stats::curr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remapPrivateView
/**
* Remaps the private view from the shared view so that it does not consume too much
* copy-on-write/swap space. Must only be called after the in-memory journal has been flushed
* to disk and applied on top of the shared view.
*
* @param fraction Value between (0, 1] indicating what fraction of the memory to remap.
* Remapping too much or too frequently incurs copy-on-write page fault cost.
*/
static void remapPrivateView(double fraction) {
// Remapping private views must occur after WRITETODATAFILES otherwise we wouldn't see any
// newly written data on reads.
invariant(!commitJob.hasWritten());
try {
Timer t;
remapPrivateViewImpl(fraction);
stats.curr()->_remapPrivateViewMicros += t.micros();
LOG(4) << "remapPrivateView end";
return;
} catch (DBException& e) {
severe() << "dbexception in remapPrivateView causing immediate shutdown: " << e.toString();
} catch (std::ios_base::failure& e) {
severe() << "ios_base exception in remapPrivateView causing immediate shutdown: "
<< e.what();
} catch (std::bad_alloc& e) {
severe() << "bad_alloc exception in remapPrivateView causing immediate shutdown: "
<< e.what();
} catch (std::exception& e) {
severe() << "exception in remapPrivateView causing immediate shutdown: " << e.what();
} catch (...) {
severe() << "unknown exception in remapPrivateView causing immediate shutdown: ";
}
invariant(false);
}
示例2: durThread
/**
* The main durability thread loop. There is a single instance of this function running.
*/
static void durThread(ClockSource* cs, int64_t serverStartMs) {
Client::initThread("durability");
log() << "Durability thread started";
bool samePartition = true;
try {
const std::string dbpathDir = boost::filesystem::path(storageGlobalParams.dbpath).string();
samePartition = onSamePartition(getJournalDir().string(), dbpathDir);
} catch (...) {
}
// Spawn the journal writer thread
JournalWriter journalWriter(&commitNotify, &applyToDataFilesNotify, NumAsyncJournalWrites);
journalWriter.start();
// Used as an estimate of how much / how fast to remap
uint64_t commitCounter(0);
uint64_t estimatedPrivateMapSize(0);
uint64_t remapLastTimestamp(0);
while (shutdownRequested.loadRelaxed() == 0) {
unsigned ms = storageGlobalParams.journalCommitIntervalMs;
if (ms == 0) {
ms = samePartition ? 100 : 30;
}
// +1 so it never goes down to zero
const int64_t oneThird = (ms / 3) + 1;
// Reset the stats based on the reset interval
if (stats.curr()->getCurrentDurationMillis() > DurStatsResetIntervalMillis) {
stats.reset();
}
try {
stdx::unique_lock<stdx::mutex> lock(flushMutex);
for (unsigned i = 0; i <= 2; i++) {
if (stdx::cv_status::no_timeout ==
flushRequested.wait_for(lock, Milliseconds(oneThird).toSystemDuration())) {
// Someone forced a flush
break;
}
if (commitNotify.nWaiting()) {
// One or more getLastError j:true is pending
break;
}
if (commitJob.bytes() > UncommittedBytesLimit / 2) {
// The number of written bytes is growing
break;
}
}
// The commit logic itself
LOG(4) << "groupCommit begin";
Timer t;
const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
OperationContext& txn = *txnPtr;
AutoAcquireFlushLockForMMAPV1Commit autoFlushLock(txn.lockState());
// We need to snapshot the commitNumber after the flush lock has been obtained,
// because at this point we know that we have a stable snapshot of the data.
const CommitNotifier::When commitNumber(commitNotify.now());
LOG(4) << "Processing commit number " << commitNumber;
if (!commitJob.hasWritten()) {
// We do not need the journal lock anymore. Free it here, for the really
// unlikely possibility that the writeBuffer command below blocks.
autoFlushLock.release();
// getlasterror request could have came after the data was already committed.
// No need to call committingReset though, because we have not done any
// writes (hasWritten == false).
JournalWriter::Buffer* const buffer = journalWriter.newBuffer();
buffer->setNoop();
buffer->journalListenerToken = getJournalListener()->getToken();
journalWriter.writeBuffer(buffer, commitNumber);
} else {
// This copies all the in-memory changes into the journal writer's buffer.
JournalWriter::Buffer* const buffer = journalWriter.newBuffer();
PREPLOGBUFFER(buffer->getHeader(), buffer->getBuilder(), cs, serverStartMs);
estimatedPrivateMapSize += commitJob.bytes();
commitCounter++;
// Now that the write intents have been copied to the buffer, the commit job is
// free to be reused. We need to reset the commit job's contents while under
// the S flush lock, because otherwise someone might have done a write and this
// would wipe out their changes without ever being committed.
commitJob.committingReset();
//.........这里部分代码省略.........