mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-17 15:25:35 +00:00
ccc7b5c9e9
loop->call(...) is similar to the old logic->Call(...), but is smart about the current thread: if called from within the event loop it simply runs the argument directly, otherwise it queues it. Similarly most of the other event loop calls are also now thread-aware: for example, `call_later(...)` can queue the job directly when called if in the event loop rather than having to double-queue through the even loop (once to call, then inside the call to initiate the time).
26 lines
415 B
C++
26 lines
415 B
C++
#include <ev/vpnio.hpp>
|
|
#include <llarp.hpp>
|
|
#include <router/abstractrouter.hpp>
|
|
|
|
void
|
|
llarp_vpn_io_impl::AsyncClose()
|
|
{
|
|
reader.queue.disable();
|
|
writer.queue.disable();
|
|
|
|
// TODO: call asynchronously
|
|
if (ctx)
|
|
ctx->CallSafe([this]() { Expunge(); });
|
|
else
|
|
Expunge();
|
|
}
|
|
|
|
void
|
|
llarp_vpn_io_impl::Expunge()
|
|
{
|
|
parent->impl = nullptr;
|
|
if (parent->closed)
|
|
parent->closed(parent);
|
|
delete this;
|
|
}
|