mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
revert back to priority queue for codel
This commit is contained in:
parent
f989996bc7
commit
885fb3cd97
7 changed files with 15 additions and 42 deletions
|
@ -116,27 +116,6 @@ namespace llarp
|
|||
}
|
||||
}
|
||||
|
||||
template < typename Q >
|
||||
void
|
||||
_sort(Q& queue)
|
||||
{
|
||||
/*
|
||||
std::vector< std::unique_ptr< T > > q;
|
||||
while(queue.size())
|
||||
{
|
||||
q.emplace_back(std::move(queue.front()));
|
||||
queue.pop();
|
||||
}
|
||||
std::sort(q.begin(), q.end(), Compare());
|
||||
auto itr = q.begin();
|
||||
while(itr != q.end())
|
||||
{
|
||||
queue.push(std::move(*itr));
|
||||
++itr;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/// visit returns true to discard entry otherwise the entry is
|
||||
/// re quened
|
||||
template < typename Visit >
|
||||
|
@ -147,13 +126,12 @@ namespace llarp
|
|||
// auto start = llarp_time_now_ms();
|
||||
// llarp::LogInfo("CoDelQueue::Process - start at ", start);
|
||||
Lock_t lock(m_QueueMutex);
|
||||
_sort(m_Queue);
|
||||
auto start = firstPut;
|
||||
std::queue< T* > requeue;
|
||||
Queue_t requeue;
|
||||
while(m_Queue.size())
|
||||
{
|
||||
llarp::LogDebug("CoDelQueue::Process - queue has ", m_Queue.size());
|
||||
T* item = m_Queue.front();
|
||||
T* item = m_Queue.top();
|
||||
auto dlt = start - GetTime()(item);
|
||||
// llarp::LogInfo("CoDelQueue::Process - dlt ", dlt);
|
||||
lowest = std::min(dlt, lowest);
|
||||
|
@ -175,14 +153,13 @@ namespace llarp
|
|||
}
|
||||
}
|
||||
// llarp::LogInfo("CoDelQueue::Process - passing");
|
||||
if(!visitor(item))
|
||||
if(visitor(item))
|
||||
{
|
||||
// requeue item as we are not done
|
||||
requeue.push(item);
|
||||
delete item;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete item;
|
||||
requeue.push(item);
|
||||
}
|
||||
m_Queue.pop();
|
||||
}
|
||||
|
@ -204,7 +181,8 @@ namespace llarp
|
|||
size_t dropNum = 0;
|
||||
llarp_time_t nextTickInterval = initialIntervalMs;
|
||||
Mutex_t m_QueueMutex;
|
||||
std::queue< T* > m_Queue;
|
||||
typedef std::priority_queue< T*, std::vector< T* >, Compare > Queue_t;
|
||||
Queue_t m_Queue;
|
||||
std::string m_name;
|
||||
};
|
||||
} // namespace util
|
||||
|
|
|
@ -201,8 +201,7 @@ struct FrameGetTime
|
|||
struct FrameCompareTime
|
||||
{
|
||||
bool
|
||||
operator()(const std::unique_ptr< iwp_async_frame > &left,
|
||||
const std::unique_ptr< iwp_async_frame > &right) const
|
||||
operator()(const iwp_async_frame *left, const iwp_async_frame *right) const
|
||||
{
|
||||
return left->created < right->created;
|
||||
}
|
||||
|
|
|
@ -84,8 +84,7 @@ namespace llarp
|
|||
struct CompareOrder
|
||||
{
|
||||
bool
|
||||
operator()(const std::unique_ptr< IPv4Packet >& left,
|
||||
const std::unique_ptr< IPv4Packet >& right)
|
||||
operator()(const IPv4Packet* left, const IPv4Packet* right)
|
||||
{
|
||||
return left->timestamp < right->timestamp;
|
||||
}
|
||||
|
|
|
@ -42,8 +42,7 @@ struct InboundMessage
|
|||
struct OrderCompare
|
||||
{
|
||||
bool
|
||||
operator()(const std::unique_ptr< InboundMessage > &left,
|
||||
const std::unique_ptr< InboundMessage > &right) const
|
||||
operator()(const InboundMessage *left, const InboundMessage *right) const
|
||||
{
|
||||
return left->msgid < right->msgid;
|
||||
}
|
||||
|
|
|
@ -65,10 +65,9 @@ struct sendbuf_t
|
|||
struct Compare
|
||||
{
|
||||
bool
|
||||
operator()(const std::unique_ptr< sendbuf_t > &left,
|
||||
const std::unique_ptr< sendbuf_t > &right) const
|
||||
operator()(const sendbuf_t *left, const sendbuf_t *right) const
|
||||
{
|
||||
return left->priority < right->priority;
|
||||
return left->timestamp < right->timestamp;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -109,8 +109,7 @@ namespace llarp
|
|||
struct Compare
|
||||
{
|
||||
bool
|
||||
operator()(const std::unique_ptr< WriteBuffer >& left,
|
||||
const std::unique_ptr< WriteBuffer >& right) const
|
||||
operator()(const WriteBuffer* left, const WriteBuffer* right) const
|
||||
{
|
||||
return left->timestamp < right->timestamp;
|
||||
}
|
||||
|
|
|
@ -98,8 +98,8 @@ namespace llarp
|
|||
{
|
||||
llarp::LogWarn("could not publish descriptors for endpoint ", Name(),
|
||||
" because we couldn't get any introductions");
|
||||
// if(ShouldBuildMore())
|
||||
ManualRebuild(1);
|
||||
if(ShouldBuildMore())
|
||||
ManualRebuild(1);
|
||||
return;
|
||||
}
|
||||
m_IntroSet.I.clear();
|
||||
|
|
Loading…
Reference in a new issue