add util::ascending_priority_queue type

pull/1907/head
Jeff 2 years ago committed by Jeff
parent 8960ca08f3
commit 14d75cc654
No known key found for this signature in database
GPG Key ID: 025C02EE3A092F2D

@ -31,6 +31,7 @@
#include <llarp/link/link_manager.hpp>
#include <llarp/tooling/dht_event.hpp>
#include <llarp/quic/tunnel.hpp>
#include <llarp/util/priority_queue.hpp>
#include <optional>
#include <utility>
@ -1629,7 +1630,7 @@ namespace llarp
session->FlushDownstream();
// handle inbound traffic sorted
std::priority_queue<ProtocolMessage> queue;
util::ascending_priority_queue<ProtocolMessage> queue;
while (not m_InboundTrafficQueue.empty())
{
// succ it out

@ -64,9 +64,9 @@ namespace llarp
ProcessAsync(path::Path_ptr p, PathID_t from, std::shared_ptr<ProtocolMessage> self);
bool
operator<(const ProtocolMessage& other) const
operator>(const ProtocolMessage& other) const
{
return other.seqno < seqno;
return seqno > other.seqno;
}
};

@ -0,0 +1,13 @@
#pragma once
#include <queue>
#include <vector>
namespace llarp::util
{
/// priority queue that uses operator > instead of operator <
template <typename T, typename Container = std::vector<T>>
using ascending_priority_queue =
std::priority_queue<T, Container, std::greater<typename Container::value_type>>;
} // namespace llarp::util
Loading…
Cancel
Save