本文整理汇总了C++中boost::optional::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ optional::isEmpty方法的具体用法?C++ optional::isEmpty怎么用?C++ optional::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::optional
的用法示例。
在下文中一共展示了optional::isEmpty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _signalNoNewDataForApplier
void BackgroundSync::_signalNoNewDataForApplier(OperationContext* txn) {
// Signal to consumers that we have entered the stopped state
// if the signal isn't already in the queue.
const boost::optional<BSONObj> lastObjectPushed = _oplogBuffer->lastObjectPushed(txn);
if (!lastObjectPushed || !lastObjectPushed->isEmpty()) {
const BSONObj sentinelDoc;
_oplogBuffer->pushEvenIfFull(txn, sentinelDoc);
bufferCountGauge.increment();
bufferSizeGauge.increment(sentinelDoc.objsize());
}
}
示例2: _producerThread
void BackgroundSync::_producerThread() {
const MemberState state = _replCoord->getMemberState();
// we want to pause when the state changes to primary
if (_replCoord->isWaitingForApplierToDrain() || state.primary()) {
if (!isPaused()) {
stop();
}
if (_replCoord->isWaitingForApplierToDrain()) {
// Signal to consumers that we have entered the paused state if the signal isn't already
// in the queue.
const boost::optional<BSONObj> lastObjectPushed = _buffer.lastObjectPushed();
if (!lastObjectPushed || !lastObjectPushed->isEmpty()) {
const BSONObj sentinelDoc;
_buffer.pushEvenIfFull(sentinelDoc);
bufferCountGauge.increment();
bufferSizeGauge.increment(sentinelDoc.objsize());
}
}
sleepsecs(1);
return;
}
// TODO(spencer): Use a condition variable to await loading a config.
if (state.startup()) {
// Wait for a config to be loaded
sleepsecs(1);
return;
}
// We need to wait until initial sync has started.
if (_replCoord->getMyLastOptime().isNull()) {
sleepsecs(1);
return;
}
// we want to unpause when we're no longer primary
// start() also loads _lastOpTimeFetched, which we know is set from the "if"
OperationContextImpl txn;
if (isPaused()) {
start(&txn);
}
_produce(&txn);
}