Rename EventLoop::udp to EventLoop::make_udp

Makes it consistent with the make_waker, etc.

Also removes some debugging.
pull/1557/head
Jason Rhinelander 3 years ago
parent afd856bca0
commit 36edabd9b0

@ -14,8 +14,8 @@ namespace llarp::dns
Proxy::Proxy(EventLoop_ptr loop, IQueryHandler* h) Proxy::Proxy(EventLoop_ptr loop, IQueryHandler* h)
: PacketHandler{loop, h}, m_Loop(std::move(loop)) : PacketHandler{loop, h}, m_Loop(std::move(loop))
{ {
m_Server = m_Server = m_Loop->make_udp(
m_Loop->udp([this](UDPHandle&, SockAddr a, OwnedBuffer buf) { HandlePacket(a, a, buf); }); [this](UDPHandle&, SockAddr a, OwnedBuffer buf) { HandlePacket(a, a, buf); });
} }
void void

@ -175,13 +175,13 @@ namespace llarp
virtual void virtual void
stop() = 0; stop() = 0;
virtual ~EventLoop() = default;
using UDPReceiveFunc = std::function<void(UDPHandle&, SockAddr src, llarp::OwnedBuffer buf)>; using UDPReceiveFunc = std::function<void(UDPHandle&, SockAddr src, llarp::OwnedBuffer buf)>;
// Constructs a UDP socket that can be used for sending and/or receiving // Constructs a UDP socket that can be used for sending and/or receiving
virtual std::shared_ptr<UDPHandle> virtual std::shared_ptr<UDPHandle>
udp(UDPReceiveFunc on_recv) = 0; make_udp(UDPReceiveFunc on_recv) = 0;
virtual ~EventLoop() = default;
/// set the function that is called once per cycle the flush all the queues /// set the function that is called once per cycle the flush all the queues
virtual void virtual void

@ -146,7 +146,7 @@ namespace llarp::uv
} }
std::shared_ptr<llarp::UDPHandle> std::shared_ptr<llarp::UDPHandle>
Loop::udp(UDPReceiveFunc on_recv) Loop::make_udp(UDPReceiveFunc on_recv)
{ {
return std::static_pointer_cast<llarp::UDPHandle>( return std::static_pointer_cast<llarp::UDPHandle>(
std::make_shared<llarp::uv::UDPHandle>(*m_Impl, std::move(on_recv))); std::make_shared<llarp::uv::UDPHandle>(*m_Impl, std::move(on_recv)));

@ -62,7 +62,7 @@ namespace llarp::uv
make_repeater() override; make_repeater() override;
std::shared_ptr<llarp::UDPHandle> std::shared_ptr<llarp::UDPHandle>
udp(UDPReceiveFunc on_recv) override; make_udp(UDPReceiveFunc on_recv) override;
void void
FlushLogic(); FlushLogic();

@ -3,7 +3,7 @@
namespace llarp namespace llarp
{ {
// Base type for UDP handling; constructed via EventLoop::udp(). // Base type for UDP handling; constructed via EventLoop::make_udp().
struct UDPHandle struct UDPHandle
{ {
using ReceiveFunc = EventLoop::UDPReceiveFunc; using ReceiveFunc = EventLoop::UDPReceiveFunc;

@ -128,10 +128,8 @@ namespace llarp
bool bool
ILinkLayer::Configure(EventLoop_ptr loop, const std::string& ifname, int af, uint16_t port) ILinkLayer::Configure(EventLoop_ptr loop, const std::string& ifname, int af, uint16_t port)
{ {
LogError("omg wtf");
m_Loop = std::move(loop); m_Loop = std::move(loop);
// using UDPReceiveFunc = std::function<void(UDPHandle&, SockAddr src, llarp::OwnedBuffer buf)>; m_udp = m_Loop->make_udp(
m_udp = m_Loop->udp(
[this]([[maybe_unused]] UDPHandle& udp, const SockAddr& from, llarp_buffer_t buf) { [this]([[maybe_unused]] UDPHandle& udp, const SockAddr& from, llarp_buffer_t buf) {
ILinkSession::Packet_t pkt; ILinkSession::Packet_t pkt;
pkt.resize(buf.sz); pkt.resize(buf.sz);

Loading…
Cancel
Save