mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
31 lines
616 B
C++
31 lines
616 B
C++
#include <ev/vpnio.hpp>
|
|
#include <llarp.hpp>
|
|
#include <router/abstractrouter.hpp>
|
|
#include <util/thread/logic.hpp>
|
|
|
|
void
|
|
llarp_vpn_io_impl::AsyncClose()
|
|
{
|
|
reader.queue.disable();
|
|
writer.queue.disable();
|
|
CallSafe(std::bind(&llarp_vpn_io_impl::Expunge, this));
|
|
}
|
|
|
|
void
|
|
llarp_vpn_io_impl::CallSafe(std::function< void(void) > f)
|
|
{
|
|
llarp::Context* ctx = llarp::Context::Get(ptr);
|
|
if(ctx && ctx->CallSafe(f))
|
|
return;
|
|
else if(ctx == nullptr || ctx->logic == nullptr)
|
|
f();
|
|
}
|
|
|
|
void
|
|
llarp_vpn_io_impl::Expunge()
|
|
{
|
|
parent->impl = nullptr;
|
|
if(parent->closed)
|
|
parent->closed(parent);
|
|
delete this;
|
|
} |