本文整理汇总了C++中intrusive_ptr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ intrusive_ptr::get方法的具体用法?C++ intrusive_ptr::get怎么用?C++ intrusive_ptr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类intrusive_ptr
的用法示例。
在下文中一共展示了intrusive_ptr::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//!Returns a.get() < b.get().
//!Does not throw
template<class T, class VP> inline
bool operator<(intrusive_ptr<T, VP> const & a,
intrusive_ptr<T, VP> const & b)
{
return std::less<typename intrusive_ptr<T, VP>::pointer>()
(a.get(), b.get());
}
示例2: sizeof
intrusive_ptr<memory_block_data> dynd::shallow_copy_array_memory_block(const intrusive_ptr<memory_block_data> &ndo)
{
// Allocate the new memory block.
const array_preamble *preamble = reinterpret_cast<const array_preamble *>(ndo.get());
size_t arrmeta_size = 0;
if (!preamble->tp.is_builtin()) {
arrmeta_size = preamble->tp->get_arrmeta_size();
}
intrusive_ptr<memory_block_data> result = make_array_memory_block(arrmeta_size);
array_preamble *result_preamble = reinterpret_cast<array_preamble *>(result.get());
// Clone the data pointer
result_preamble->data = preamble->data;
result_preamble->owner = preamble->owner;
if (!result_preamble->owner) {
result_preamble->owner = ndo.get();
}
// Copy the flags
result_preamble->flags = preamble->flags;
// Clone the type
result_preamble->tp = preamble->tp;
if (!preamble->tp.is_builtin()) {
preamble->tp.extended()->arrmeta_copy_construct(reinterpret_cast<char *>(result.get()) + sizeof(array_preamble),
reinterpret_cast<const char *>(ndo.get()) + sizeof(array_preamble),
ndo);
}
return result;
}
示例3: writeExplainMongos
void Pipeline::writeExplainMongos(
BSONObjBuilder &result,
const intrusive_ptr<DocumentSource> &pInputSource) const {
/*
For now, this should be a BSON source array.
In future, we might have a more clever way of getting this, when
we have more interleaved fetching between shards. The DocumentSource
interface will have to change to accommodate that.
*/
DocumentSourceBsonArray *pSourceBsonArray =
dynamic_cast<DocumentSourceBsonArray *>(pInputSource.get());
verify(pSourceBsonArray);
BSONArrayBuilder shardOpArray; // where we'll put the pipeline ops
for(bool hasDocument = !pSourceBsonArray->eof(); hasDocument;
hasDocument = pSourceBsonArray->advance()) {
intrusive_ptr<Document> pDocument(
pSourceBsonArray->getCurrent());
BSONObjBuilder opBuilder;
pDocument->toBson(&opBuilder);
shardOpArray.append(opBuilder.obj());
}
BSONArrayBuilder mongosOpArray; // where we'll put the pipeline ops
writeExplainOps(&mongosOpArray);
// now we combine the shard pipelines with the one here
result.append(serverPipelineName, shardOpArray.arr());
result.append(mongosPipelineName, mongosOpArray.arr());
}
示例4: request_bandwidth
// non prioritized means that, if there's a line for bandwidth,
// others will cut in front of the non-prioritized peers.
// this is used by web seeds
void request_bandwidth(intrusive_ptr<PeerConnection> const& peer
, int blk, int priority
, bandwidth_channel* chan1 = 0
, bandwidth_channel* chan2 = 0
, bandwidth_channel* chan3 = 0
, bandwidth_channel* chan4 = 0
, bandwidth_channel* chan5 = 0
)
{
INVARIANT_CHECK;
if (m_abort) return;
TORRENT_ASSERT(blk > 0);
TORRENT_ASSERT(priority > 0);
TORRENT_ASSERT(!is_queued(peer.get()));
bw_request<PeerConnection> bwr(peer, blk, priority);
int i = 0;
if (chan1 && chan1->throttle() > 0) bwr.channel[i++] = chan1;
if (chan2 && chan2->throttle() > 0) bwr.channel[i++] = chan2;
if (chan3 && chan3->throttle() > 0) bwr.channel[i++] = chan3;
if (chan4 && chan4->throttle() > 0) bwr.channel[i++] = chan4;
if (chan5 && chan5->throttle() > 0) bwr.channel[i++] = chan5;
if (i == 0)
{
// the connection is not rate limited by any of its
// bandwidth channels, or it doesn't belong to any
// channels. There's no point in adding it to
// the queue, just satisfy the request immediately
bwr.peer->assign_bandwidth(m_channel, blk);
return;
}
m_queued_bytes += blk;
m_queue.push_back(bwr);
}
示例5: coalesce
bool DocumentSourceSort::coalesce(const intrusive_ptr<DocumentSource>& pNextSource) {
if (!limitSrc) {
limitSrc = dynamic_cast<DocumentSourceLimit*>(pNextSource.get());
return limitSrc.get(); // false if next is not a $limit
} else {
return limitSrc->coalesce(pNextSource);
}
}
示例6: to_string
std::string to_string(const intrusive_ptr<T>& x) {
auto v = reinterpret_cast<uintptr_t>(x.get());
// we convert to hex representation, i.e.,
// one byte takes two characters + null terminator + "0x" prefix
char buf[sizeof(v) * 2 + 3];
sprintf(buf, "%" PRIxPTR, v);
return buf;
}
示例7: get_detached
pointer get_detached() {
auto ptr = m_ptr.get();
if (!ptr->unique()) {
pointer new_ptr = ptr->copy();
reset(new_ptr);
return new_ptr;
}
return ptr;
}
示例8: coalesce
bool DocumentSourceGeoNear::coalesce(const intrusive_ptr<DocumentSource> &pNextSource) {
DocumentSourceLimit* limitSrc = dynamic_cast<DocumentSourceLimit*>(pNextSource.get());
if (limitSrc) {
limit = min(limit, limitSrc->getLimit());
return true;
}
return false;
}
示例9: coalesce
bool DocumentSourceSkip::coalesce(const intrusive_ptr<DocumentSource>& pNextSource) {
DocumentSourceSkip* pSkip = dynamic_cast<DocumentSourceSkip*>(pNextSource.get());
/* if it's not another $skip, we can't coalesce */
if (!pSkip)
return false;
/* we need to skip over the sum of the two consecutive $skips */
_skip += pSkip->_skip;
return true;
}
示例10: detach_ptr
T* detach_ptr()
{
T* ptr = m_ptr.get();
if (!ptr->unique())
{
T* new_ptr = detail::copy_of(ptr, copy_of_token());
cow_ptr tmp(new_ptr);
swap(tmp);
return new_ptr;
}
return ptr;
}
示例11: coalesce
bool DocumentSourceLookUp::coalesce(const intrusive_ptr<DocumentSource>& pNextSource) {
if (_handlingUnwind) {
return false;
}
auto unwindSrc = dynamic_cast<DocumentSourceUnwind*>(pNextSource.get());
if (!unwindSrc || unwindSrc->getUnwindPath() != _as.getPath(false)) {
return false;
}
_unwindSrc = std::move(unwindSrc);
_handlingUnwind = true;
return true;
}
示例12: setField
void Document::setField(size_t index,
const string &fieldName,
const intrusive_ptr<const Value> &pValue) {
/* special case: should this field be removed? */
if (!pValue.get()) {
vFieldName.erase(vFieldName.begin() + index);
vpValue.erase(vpValue.begin() + index);
return;
}
/* set the indicated field */
vFieldName[index] = fieldName;
vpValue[index] = pValue;
}
示例13: coalesce
bool DocumentSourceCursor::coalesce(const intrusive_ptr<DocumentSource>& nextSource) {
// Note: Currently we assume the $limit is logically after any $sort or
// $match. If we ever pull in $match or $sort using this method, we
// will need to keep track of the order of the sub-stages.
if (!_limit) {
_limit = dynamic_cast<DocumentSourceLimit*>(nextSource.get());
return _limit.get(); // false if next is not a $limit
} else {
return _limit->coalesce(nextSource);
}
return false;
}
示例14: coalesce
bool DocumentSourceLimit::coalesce(
const intrusive_ptr<DocumentSource> &pNextSource) {
DocumentSourceLimit *pLimit =
dynamic_cast<DocumentSourceLimit *>(pNextSource.get());
/* if it's not another $limit, we can't coalesce */
if (!pLimit)
return false;
/* we need to limit by the minimum of the two limits */
if (pLimit->limit < limit)
limit = pLimit->limit;
return true;
}
示例15: run
bool Pipeline::run(BSONObjBuilder &result, string &errmsg,
const intrusive_ptr<DocumentSource> &pInputSource) {
/* chain together the sources we found */
DocumentSource *pSource = pInputSource.get();
for(SourceVector::iterator iter(sourceVector.begin()),
listEnd(sourceVector.end()); iter != listEnd; ++iter) {
intrusive_ptr<DocumentSource> pTemp(*iter);
pTemp->setSource(pSource);
pSource = pTemp.get();
}
/* pSource is left pointing at the last source in the chain */
/*
Iterate through the resulting documents, and add them to the result.
We do this even if we're doing an explain, in order to capture
the document counts and other stats. However, we don't capture
the result documents for explain.
*/
if (explain) {
if (!pCtx->getInRouter())
writeExplainShard(result, pInputSource);
else {
writeExplainMongos(result, pInputSource);
}
}
else {
// the array in which the aggregation results reside
// cant use subArrayStart() due to error handling
BSONArrayBuilder resultArray;
for(bool hasDoc = !pSource->eof(); hasDoc; hasDoc = pSource->advance()) {
intrusive_ptr<Document> pDocument(pSource->getCurrent());
/* add the document to the result set */
BSONObjBuilder documentBuilder (resultArray.subobjStart());
pDocument->toBson(&documentBuilder);
documentBuilder.doneFast();
// object will be too large, assert. the extra 1KB is for headers
uassert(16389,
str::stream() << "aggregation result exceeds maximum document size ("
<< BSONObjMaxUserSize / (1024 * 1024) << "MB)",
resultArray.len() < BSONObjMaxUserSize - 1024);
}
resultArray.done();
result.appendArray("result", resultArray.arr());
}
return true;
}