本文整理汇总了C++中intrusive_ptr::max_assignable_bandwidth方法的典型用法代码示例。如果您正苦于以下问题:C++ intrusive_ptr::max_assignable_bandwidth方法的具体用法?C++ intrusive_ptr::max_assignable_bandwidth怎么用?C++ intrusive_ptr::max_assignable_bandwidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类intrusive_ptr
的用法示例。
在下文中一共展示了intrusive_ptr::max_assignable_bandwidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: request_bandwidth
void bandwidth_manager::request_bandwidth(intrusive_ptr<peer_connection> peer
, bool non_prioritized)
{
INVARIANT_CHECK;
assert(!peer->ignore_bandwidth_limits());
// make sure this peer isn't already in line
// waiting for bandwidth
#ifndef NDEBUG
for (std::deque<bw_queue_entry>::iterator i = m_queue.begin()
, end(m_queue.end()); i != end; ++i)
{
assert(i->peer < peer || peer < i->peer);
}
#endif
assert(peer->max_assignable_bandwidth(m_channel) > 0);
// if the queue is empty, we have to push the new
// peer at the back of it. If the peer is non-prioritized
// it is not supposed to cut in fron of anybody, so then
// we also just add it at the end
if (m_queue.empty() || non_prioritized)
{
m_queue.push_back(bw_queue_entry(peer, non_prioritized));
}
else
{
// skip forward in the queue until we find a prioritized peer
// or hit the front of it.
std::deque<bw_queue_entry>::reverse_iterator i = m_queue.rbegin();
while (i != m_queue.rend() && i->non_prioritized) ++i;
m_queue.insert(i.base(), bw_queue_entry(peer, non_prioritized));
}
if (m_queue.size() == 1) hand_out_bandwidth();
}