convert priority queues

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

@ -12,10 +12,12 @@
#include <llarp/vpn/packet_router.hpp>
#include <future>
#include <queue>
#include <type_traits>
#include <variant>
#include <llarp/service/protocol_type.hpp>
#include <llarp/util/priority_queue.hpp>
namespace llarp
{
@ -185,14 +187,14 @@ namespace llarp
net::IPPacket pkt;
bool
operator<(const WritePacket& other) const
operator>(const WritePacket& other) const
{
return other.seqno < seqno;
return seqno > other.seqno;
}
};
/// queue for sending packets to user from network
std::priority_queue<WritePacket> m_NetworkToUserPktQueue;
util::ascending_priority_queue<WritePacket> m_NetworkToUserPktQueue;
void
Pump(llarp_time_t now) override;

@ -260,15 +260,15 @@ namespace llarp
OutboundMessage*,
std::vector<OutboundMessage*>,
ComparePtr<OutboundMessage*>>
resend;
to_resend;
for (auto& [id, msg] : m_TXMsgs)
{
if (msg.ShouldFlush(now))
resend.push(&msg);
to_resend.push(&msg);
}
if (not resend.empty())
if (not to_resend.empty())
{
for (auto& msg = resend.top(); not resend.empty(); resend.pop())
for (auto& msg = to_resend.top(); not to_resend.empty(); to_resend.pop())
msg->FlushUnAcked(util::memFn(&Session::EncryptAndSend, this), now);
}
}

@ -8,8 +8,8 @@
#include <map>
#include <unordered_set>
#include <deque>
#include <queue>
#include <llarp/util/priority_queue.hpp>
#include <llarp/util/thread/queue.hpp>
namespace llarp
@ -197,7 +197,7 @@ namespace llarp
/// maps rxid to time recieved
std::unordered_map<uint64_t, llarp_time_t> m_ReplayFilter;
/// rx messages to send in next round of multiacks
std::priority_queue<uint64_t, std::vector<uint64_t>, std::greater<>> m_SendMACKs;
util::ascending_priority_queue<uint64_t> m_SendMACKs;
using CryptoQueue_t = std::vector<Packet_t>;

@ -6,12 +6,12 @@
#include <llarp/util/thread/queue.hpp>
#include <llarp/util/decaying_hashset.hpp>
#include <llarp/path/path_types.hpp>
#include <llarp/util/priority_queue.hpp>
#include <llarp/router_id.hpp>
#include <list>
#include <unordered_map>
#include <utility>
#include <queue>
struct llarp_buffer_t;
@ -86,9 +86,9 @@ namespace llarp
RouterID router;
bool
operator<(const MessageQueueEntry& other) const
operator>(const MessageQueueEntry& other) const
{
return other.priority < priority;
return priority > other.priority;
}
};
@ -103,7 +103,7 @@ namespace llarp
uint32_t numTicks = 0;
};
using MessageQueue = std::priority_queue<MessageQueueEntry>;
using MessageQueue = util::ascending_priority_queue<MessageQueueEntry>;
/* If a session is not yet created with the destination router for a message,
* a special queue is created for that router and an attempt is made to

Loading…
Cancel
Save