![]() |
Bitcoin Core 29.99.0
P2P Digital Currency
|
Object holding network & rpc state associated with either an incoming server connection, or an outgoing client connection. More...
#include <proxy-io.h>
Public Member Functions | |
Connection (EventLoop &loop, kj::Own< kj::AsyncIoStream > &&stream_) | |
Connection (EventLoop &loop, kj::Own< kj::AsyncIoStream > &&stream_, const std::function<::capnp::Capability::Client(Connection &)> &make_client) | |
~Connection () | |
Run cleanup functions. More... | |
CleanupIt | addSyncCleanup (std::function< void()> fn) |
Register synchronous cleanup function to run on event loop thread (with access to capnp thread local variables) when disconnect() is called. More... | |
void | removeSyncCleanup (CleanupIt it) |
void | addAsyncCleanup (std::function< void()> fn) |
Register asynchronous cleanup function to run on worker thread when disconnect() is called. More... | |
template<typename F > | |
void | onDisconnect (F &&f) |
Add disconnect handler. More... | |
Public Attributes | |
EventLoop & | m_loop |
kj::Own< kj::AsyncIoStream > | m_stream |
LoggingErrorHandler | m_error_handler {m_loop} |
kj::TaskSet | m_on_disconnect {m_error_handler} |
::capnp::TwoPartyVatNetwork | m_network |
std::optional<::capnp::RpcSystem<::capnp::rpc::twoparty::VatId > > | m_rpc_system |
ThreadMap::Client | m_thread_map {nullptr} |
::capnp::CapabilityServerSet< Thread > | m_threads |
Collection of server-side IPC worker threads (ProxyServer<Thread> objects previously returned by ThreadMap.makeThread) used to service requests to clients. More... | |
CleanupList | m_sync_cleanup_fns |
Cleanup functions to run if connection is broken unexpectedly. More... | |
CleanupList | m_async_cleanup_fns |
Object holding network & rpc state associated with either an incoming server connection, or an outgoing client connection.
It must be created and destroyed on the event loop thread. In addition to Cap'n Proto state, it also holds lists of callbacks to run when the connection is closed.
Definition at line 287 of file proxy-io.h.
|
inline |
|
inline |
mp::Connection::~Connection | ( | ) |
Run cleanup functions.
Must be called from the event loop thread. First calls synchronous cleanup functions while blocked (to free capnp Capability::Client handles owned by ProxyClient objects), then schedules asynchronous cleanup functions to run in a worker thread (to run destructors of m_impl instances owned by ProxyServer objects).
Definition at line 51 of file proxy.cpp.
void mp::Connection::addAsyncCleanup | ( | std::function< void()> | fn | ) |
CleanupIt mp::Connection::addSyncCleanup | ( | std::function< void()> | fn | ) |
|
inline |
Add disconnect handler.
Definition at line 328 of file proxy-io.h.
void mp::Connection::removeSyncCleanup | ( | CleanupIt | it | ) |
CleanupList mp::Connection::m_async_cleanup_fns |
Definition at line 358 of file proxy-io.h.
LoggingErrorHandler mp::Connection::m_error_handler {m_loop} |
Definition at line 341 of file proxy-io.h.
EventLoop& mp::Connection::m_loop |
Definition at line 339 of file proxy-io.h.
::capnp::TwoPartyVatNetwork mp::Connection::m_network |
Definition at line 343 of file proxy-io.h.
kj::TaskSet mp::Connection::m_on_disconnect {m_error_handler} |
Definition at line 342 of file proxy-io.h.
std::optional<::capnp::RpcSystem<::capnp::rpc::twoparty::VatId> > mp::Connection::m_rpc_system |
Definition at line 344 of file proxy-io.h.
kj::Own<kj::AsyncIoStream> mp::Connection::m_stream |
Definition at line 340 of file proxy-io.h.
CleanupList mp::Connection::m_sync_cleanup_fns |
Cleanup functions to run if connection is broken unexpectedly.
Lists will be empty if all ProxyClient and ProxyServer objects are destroyed cleanly before the connection is destroyed.
Definition at line 357 of file proxy-io.h.
ThreadMap::Client mp::Connection::m_thread_map {nullptr} |
Definition at line 348 of file proxy-io.h.
::capnp::CapabilityServerSet<Thread> mp::Connection::m_threads |
Collection of server-side IPC worker threads (ProxyServer<Thread> objects previously returned by ThreadMap.makeThread) used to service requests to clients.
Definition at line 352 of file proxy-io.h.