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 <future>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
namespace uvw
|
||||||
|
{
|
||||||
|
class Loop;
|
||||||
|
}
|
||||||
|
|
||||||
namespace llarp
|
namespace llarp
|
||||||
{
|
{
|
||||||
struct SockAddr;
|
struct SockAddr;
|
||||||
@ -214,6 +219,14 @@ namespace llarp
|
|||||||
// Returns true if called from within the event loop thread, false otherwise.
|
// Returns true if called from within the event loop thread, false otherwise.
|
||||||
virtual bool
|
virtual bool
|
||||||
inEventLoop() const = 0;
|
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>;
|
using EventLoop_ptr = std::shared_ptr<EventLoop>;
|
||||||
|
@ -13,11 +13,9 @@
|
|||||||
namespace llarp::uv
|
namespace llarp::uv
|
||||||
{
|
{
|
||||||
std::shared_ptr<uvw::Loop>
|
std::shared_ptr<uvw::Loop>
|
||||||
Loop::MaybeGetLoop(const EventLoop_ptr& ptr)
|
Loop::MaybeGetUVWLoop()
|
||||||
{
|
{
|
||||||
if (auto* uv = dynamic_cast<Loop*>(ptr.get()))
|
return m_Impl;
|
||||||
return uv->m_Impl;
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class UVWakeup final : public EventLoopWakeup
|
class UVWakeup final : public EventLoopWakeup
|
||||||
|
@ -71,8 +71,8 @@ namespace llarp::uv
|
|||||||
|
|
||||||
std::function<void(void)> PumpLL;
|
std::function<void(void)> PumpLL;
|
||||||
|
|
||||||
static std::shared_ptr<uvw::Loop>
|
std::shared_ptr<uvw::Loop>
|
||||||
MaybeGetLoop(const EventLoop_ptr&);
|
MaybeGetUVWLoop() override;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
inEventLoop() const override;
|
inEventLoop() const override;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
namespace llarp::quic
|
namespace llarp::quic
|
||||||
{
|
{
|
||||||
Client::Client(service::ConvoTag tag, service::Endpoint* parent, uint16_t tunnel_port)
|
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
|
// Our UDP socket is now set up, so now we initiate contact with the remote QUIC
|
||||||
Address remote{std::move(tag)};
|
Address remote{std::move(tag)};
|
||||||
|
@ -83,7 +83,8 @@ namespace llarp
|
|||||||
m_StartupLNSMappings[name] = std::make_pair(range, auth);
|
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](
|
auto callback = [this, loop, ports = conf.m_quicServerPorts](
|
||||||
quic::Server& serv, quic::Stream& stream, uint16_t port) {
|
quic::Server& serv, quic::Stream& stream, uint16_t port) {
|
||||||
if (ports.count(port) == 0)
|
if (ports.count(port) == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user