mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
Change MaybeGetLoop to a virtual member func
Minor simplification.
This commit is contained in:
parent
a1a1b2e2bc
commit
104f63543f
@ -11,6 +11,11 @@
|
||||
#include <future>
|
||||
#include <utility>
|
||||
|
||||
namespace uvw
|
||||
{
|
||||
class Loop;
|
||||
}
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
struct SockAddr;
|
||||
@ -214,6 +219,14 @@ namespace llarp
|
||||
// Returns true if called from within the event loop thread, false otherwise.
|
||||
virtual bool
|
||||
inEventLoop() const = 0;
|
||||
|
||||
// Returns the uvw::Loop *if* this event loop is backed by a uvw event loop (i.e. the default),
|
||||
// nullptr otherwise. (This base class default always returns nullptr).
|
||||
virtual std::shared_ptr<uvw::Loop>
|
||||
MaybeGetUVWLoop()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
using EventLoop_ptr = std::shared_ptr<EventLoop>;
|
||||
|
@ -13,11 +13,9 @@
|
||||
namespace llarp::uv
|
||||
{
|
||||
std::shared_ptr<uvw::Loop>
|
||||
Loop::MaybeGetLoop(const EventLoop_ptr& ptr)
|
||||
Loop::MaybeGetUVWLoop()
|
||||
{
|
||||
if (auto* uv = dynamic_cast<Loop*>(ptr.get()))
|
||||
return uv->m_Impl;
|
||||
return nullptr;
|
||||
return m_Impl;
|
||||
}
|
||||
|
||||
class UVWakeup final : public EventLoopWakeup
|
||||
|
@ -71,8 +71,8 @@ namespace llarp::uv
|
||||
|
||||
std::function<void(void)> PumpLL;
|
||||
|
||||
static std::shared_ptr<uvw::Loop>
|
||||
MaybeGetLoop(const EventLoop_ptr&);
|
||||
std::shared_ptr<uvw::Loop>
|
||||
MaybeGetUVWLoop() override;
|
||||
|
||||
bool
|
||||
inEventLoop() const override;
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace llarp::quic
|
||||
{
|
||||
Client::Client(service::ConvoTag tag, service::Endpoint* parent, uint16_t tunnel_port)
|
||||
: Endpoint{parent, uv::Loop::MaybeGetLoop(parent->Loop())}
|
||||
: Endpoint{parent, parent->Loop()->MaybeGetUVWLoop()}
|
||||
{
|
||||
// Our UDP socket is now set up, so now we initiate contact with the remote QUIC
|
||||
Address remote{std::move(tag)};
|
||||
|
@ -83,7 +83,8 @@ namespace llarp
|
||||
m_StartupLNSMappings[name] = std::make_pair(range, auth);
|
||||
});
|
||||
|
||||
auto loop = uv::Loop::MaybeGetLoop(Router()->loop());
|
||||
auto loop = Router()->loop()->MaybeGetUVWLoop();
|
||||
assert(loop);
|
||||
auto callback = [this, loop, ports = conf.m_quicServerPorts](
|
||||
quic::Server& serv, quic::Stream& stream, uint16_t port) {
|
||||
if (ports.count(port) == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user