Bitcoin Core 29.99.0
P2P Digital Currency
Public Types | Public Member Functions | Public Attributes | List of all members
mp::ProxyServerBase< Interface_, Impl_ > Struct Template Reference

Base class for generated ProxyServer classes that implement capnp server methods and forward calls to a wrapped c++ implementation class. More...

#include <proxy.h>

Inheritance diagram for mp::ProxyServerBase< Interface_, Impl_ >:
[legend]
Collaboration diagram for mp::ProxyServerBase< Interface_, Impl_ >:
[legend]

Public Types

using Interface = Interface_
 
using Impl = Impl_
 

Public Member Functions

 ProxyServerBase (std::shared_ptr< Impl > impl, Connection &connection)
 
virtual ~ProxyServerBase ()
 ProxyServer destructor, called from the EventLoop thread by Cap'n Proto garbage collection code after there are no more references to this object. More...
 
void invokeDestroy ()
 If the capnp interface defined a special "destroy" method, as described the ProxyClientBase class, this method will be called and synchronously destroy m_impl before returning to the client. More...
 

Public Attributes

std::shared_ptr< Implm_impl
 Implementation pointer that may or may not be owned and deleted when this capnp server goes out of scope. More...
 
ProxyContext m_context
 

Detailed Description

template<typename Interface_, typename Impl_>
struct mp::ProxyServerBase< Interface_, Impl_ >

Base class for generated ProxyServer classes that implement capnp server methods and forward calls to a wrapped c++ implementation class.

Definition at line 147 of file proxy.h.

Member Typedef Documentation

◆ Impl

template<typename Interface_ , typename Impl_ >
using mp::ProxyServerBase< Interface_, Impl_ >::Impl = Impl_

Definition at line 151 of file proxy.h.

◆ Interface

template<typename Interface_ , typename Impl_ >
using mp::ProxyServerBase< Interface_, Impl_ >::Interface = Interface_

Definition at line 150 of file proxy.h.

Constructor & Destructor Documentation

◆ ProxyServerBase()

template<typename Interface , typename Impl >
mp::ProxyServerBase< Interface, Impl >::ProxyServerBase ( std::shared_ptr< Impl impl,
Connection connection 
)

Definition at line 464 of file proxy-io.h.

Here is the call graph for this function:

◆ ~ProxyServerBase()

template<typename Interface , typename Impl >
mp::ProxyServerBase< Interface, Impl >::~ProxyServerBase
virtual

ProxyServer destructor, called from the EventLoop thread by Cap'n Proto garbage collection code after there are no more references to this object.

This will typically happen when the corresponding ProxyClient object on the other side of the connection is destroyed. It can also happen earlier if the connection is broken or destroyed. In the latter case this destructor will typically be called inside m_rpc_system.reset() call in the ~Connection destructor while the Connection object still exists. However, because ProxyServer objects are refcounted, and the Connection object could be destroyed while asynchronous IPC calls are still in-flight, it's possible for this destructor to be called after the Connection object no longer exists, so it is NOT valid to dereference the m_context.connection pointer from this function.

Definition at line 483 of file proxy-io.h.

Here is the call graph for this function:

Member Function Documentation

◆ invokeDestroy()

template<typename Interface , typename Impl >
void mp::ProxyServerBase< Interface, Impl >::invokeDestroy

If the capnp interface defined a special "destroy" method, as described the ProxyClientBase class, this method will be called and synchronously destroy m_impl before returning to the client.

If the capnp interface does not define a "destroy" method, this will never be called and the ~ProxyServerBase destructor will be responsible for deleting m_impl asynchronously, whenever the ProxyServer object gets garbage collected by Cap'n Proto.

This method is called in the same way other proxy server methods are called, via the serverInvoke function. Basically serverInvoke just calls this as a substitute for a non-existent m_impl->destroy() method. If the destroy method has any parameters or return values they will be handled in the normal way by PassField/ReadField/BuildField functions. Particularly if a Context.thread parameter was passed, this method will run on the worker thread specified by the client. Otherwise it will run on the EventLoop thread, like other server methods without an assigned thread.

Definition at line 531 of file proxy-io.h.

Here is the call graph for this function:

Member Data Documentation

◆ m_context

template<typename Interface_ , typename Impl_ >
ProxyContext mp::ProxyServerBase< Interface_, Impl_ >::m_context

Definition at line 171 of file proxy.h.

◆ m_impl

template<typename Interface_ , typename Impl_ >
std::shared_ptr<Impl> mp::ProxyServerBase< Interface_, Impl_ >::m_impl

Implementation pointer that may or may not be owned and deleted when this capnp server goes out of scope.

It is owned for servers created to wrap unique_ptr<Impl> method arguments, but unowned for servers created to wrap Impl& method arguments.

In the case of Impl& arguments, custom code is required on other side of the connection to delete the capnp client & server objects since native code on that side of the connection will just be taking a plain reference rather than a pointer, so won't be able to do its own cleanup. Right now this is implemented with addCloseHook callbacks to delete clients at appropriate times depending on semantics of the particular method being wrapped.

Definition at line 170 of file proxy.h.


The documentation for this struct was generated from the following files: