// 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 int bandwidth_manager::request_bandwidth(boost::intrusive_ptr<bandwidth_socket> const& peer , int blk, int priority , bandwidth_channel* chan1 , bandwidth_channel* chan2 , bandwidth_channel* chan3 , bandwidth_channel* chan4 , bandwidth_channel* chan5 ) { INVARIANT_CHECK; if (m_abort) return 0; TORRENT_ASSERT(blk > 0); TORRENT_ASSERT(priority > 0); TORRENT_ASSERT(!is_queued(peer.get())); bw_request 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 return blk; } m_queued_bytes += blk; m_queue.push_back(bwr); return 0; }
int seekLowerBound(fstring key, llong* id, valvec<byte>* retKey) override { assert(key.size() == sizeof(Int)); if (key.size() != sizeof(Int)) { THROW_STD(invalid_argument, "key.size must be sizeof(Int)=%d", int(sizeof(Int))); } auto owner = static_cast<const SeqNumIndex*>(m_index.get()); Int keyId = unaligned_load<Int>(key.udata()); if (keyId <= owner->m_min) { m_curr = 0; return -1; } else if (keyId > owner->m_min + owner->m_cnt) { m_curr = owner->m_cnt; *id = owner->m_cnt - 1; Int forwardMax = owner->m_min + owner->m_cnt - 1; retKey->assign((const byte*)&forwardMax, sizeof(Int)); return 1; } else { keyId -= owner->m_min; m_curr = keyId; *id = keyId; retKey->assign(key.udata(), key.size()); return 0; } }
void launcher_class_init(as_object &obj) { // GNASH_REPORT_FUNCTION; // This is going to be the global "class"/"function" static boost::intrusive_ptr<builtin_function> cl; if (cl == NULL) { Global_as* gl = getGlobal(global); as_object* proto = getInterface(); cl = gl->createClass(&launcher_ctor, proto); // // replicate all interface to class, to be able to access // // all methods as static functions attachInterface(cl.get()); } obj.init_member("Launcher", cl.get()); }
bool increment(llong* id, valvec<byte>* key) override { auto owner = static_cast<const SeqNumIndex*>(m_index.get()); if (nark_likely(m_curr < owner->m_cnt)) { getIndexKey(id, key, owner, --m_curr); return true; } return false; }
static as_object* getInterface() { GNASH_REPORT_FUNCTION; static boost::intrusive_ptr<as_object> o; if (o == NULL) { o = new as_object(); } return o.get(); }
inline void save(Archive& ar, boost::intrusive_ptr<T> const& t, unsigned int const) { // The most common cause of trapping here would be serializing // something like intrusive_ptr<int>. This occurs because int // is never tracked by default. Wrap int in a trackable type BOOST_STATIC_ASSERT((tracking_level<T>::value != track_never)); T const* ptr = t.get(); ar << ptr; }
// static StatusWith<std::unique_ptr<CanonicalQuery>> CanonicalQuery::canonicalize( OperationContext* opCtx, std::unique_ptr<QueryRequest> qr, const boost::intrusive_ptr<ExpressionContext>& expCtx, const ExtensionsCallback& extensionsCallback, MatchExpressionParser::AllowedFeatureSet allowedFeatures) { auto qrStatus = qr->validate(); if (!qrStatus.isOK()) { return qrStatus; } std::unique_ptr<CollatorInterface> collator; if (!qr->getCollation().isEmpty()) { auto statusWithCollator = CollatorFactoryInterface::get(opCtx->getServiceContext()) ->makeFromBSON(qr->getCollation()); if (!statusWithCollator.isOK()) { return statusWithCollator.getStatus(); } collator = std::move(statusWithCollator.getValue()); } // Make MatchExpression. boost::intrusive_ptr<ExpressionContext> newExpCtx; if (!expCtx.get()) { newExpCtx.reset(new ExpressionContext(opCtx, collator.get())); } else { newExpCtx = expCtx; invariant(CollatorInterface::collatorsMatch(collator.get(), expCtx->getCollator())); } StatusWithMatchExpression statusWithMatcher = MatchExpressionParser::parse( qr->getFilter(), newExpCtx, extensionsCallback, allowedFeatures); if (!statusWithMatcher.isOK()) { return statusWithMatcher.getStatus(); } std::unique_ptr<MatchExpression> me = std::move(statusWithMatcher.getValue()); // Make the CQ we'll hopefully return. std::unique_ptr<CanonicalQuery> cq(new CanonicalQuery()); Status initStatus = cq->init(opCtx, std::move(qr), parsingCanProduceNoopMatchNodes(extensionsCallback, allowedFeatures), std::move(me), std::move(collator)); if (!initStatus.isOK()) { return initStatus; } return std::move(cq); }
template<class T> void test3(boost::intrusive_ptr<T> const & p, boost::intrusive_ptr<T> const & q) { BOOST_TEST((p == q) == (p.get() == q.get())); BOOST_TEST((p.get() == q) == (p.get() == q.get())); BOOST_TEST((p == q.get()) == (p.get() == q.get())); BOOST_TEST((p != q) == (p.get() != q.get())); BOOST_TEST((p.get() != q) == (p.get() != q.get())); BOOST_TEST((p != q.get()) == (p.get() != q.get())); // 'less' moved here as a g++ 2.9x parse error workaround std::less<T*> less; BOOST_TEST((p < q) == less(p.get(), q.get())); }
template<class T, class U> void test2(boost::intrusive_ptr<T> const & p, boost::intrusive_ptr<U> const & q) { BOOST_TEST((p == q) == (p.get() == q.get())); BOOST_TEST((p != q) == (p.get() != q.get())); }
ScopedSetBroker(const boost::intrusive_ptr<Broker>& broker) { qpid::broker::SignalHandler::setBroker(broker.get()); }
void reset() override { auto owner = static_cast<const SeqNumIndex*>(m_index.get()); m_curr = owner->m_cnt; }
void save(Archive & ar, ::boost::intrusive_ptr<T> const & ptr, uint32_t version) { T * t = ptr.get(); ar & t; }
void enqueue(TransactionContext* , const boost::intrusive_ptr<PersistableMessage>& pmsg, const PersistableQueue& ) { qpid::broker::amqp_0_10::MessageTransfer* msg = dynamic_cast<qpid::broker::amqp_0_10::MessageTransfer*>(pmsg.get()); assert(msg); // Dump the message if there is a dump file. if (dump.get()) { msg->getFrames().getMethod()->print(*dump); *dump << endl << " "; msg->getFrames().getHeaders()->print(*dump); *dump << endl << " "; *dump << msg->getFrames().getContentSize() << endl; } // Check the message for special instructions. string data = msg->getFrames().getContent(); size_t i = string::npos; size_t j = string::npos; if (strncmp(data.c_str(), TEST_STORE_DO.c_str(), strlen(TEST_STORE_DO.c_str())) == 0 && (i = data.find(name+"[")) != string::npos && (j = data.find("]", i)) != string::npos) { size_t start = i+name.size()+1; string action = data.substr(start, j-start); if (action == EXCEPTION) { throw Exception(QPID_MSG("TestStore " << name << " throwing exception for: " << data)); } else if (action == EXIT_PROCESS) { // FIXME aconway 2009-04-10: this is a dubious way to // close the process at best, it can cause assertions or seg faults // rather than clean exit. QPID_LOG(critical, "TestStore " << name << " forcing process exit for: " << data); exit(0); } else if (strncmp(action.c_str(), ASYNC.c_str(), strlen(ASYNC.c_str())) == 0) { std::string delayStr(action.substr(ASYNC.size())); int delay = boost::lexical_cast<int>(delayStr); threads.push_back(Thread(*new Completer(msg, delay))); } else { QPID_LOG(error, "TestStore " << name << " unknown action " << action); msg->enqueueComplete(); } } else msg->enqueueComplete(); }