Bitcoin Core 29.99.0
P2P Digital Currency
List of all members
mp::ProxyServerCustom< Interface, Impl > Struct Template Reference

Customizable (through template specialization) base class which ProxyServer classes produced by generated code will inherit from. More...

#include <proxy.h>

Inheritance diagram for mp::ProxyServerCustom< Interface, Impl >:
[legend]
Collaboration diagram for mp::ProxyServerCustom< Interface, Impl >:
[legend]

Additional Inherited Members

- Public Types inherited from mp::ProxyServerBase< Interface, Impl >
using Interface = Interface
 
using Impl = Impl
 
- Public Member Functions inherited from mp::ProxyServerBase< Interface, Impl >
 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 inherited from mp::ProxyServerBase< Interface, Impl >
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::ProxyServerCustom< Interface, Impl >

Customizable (through template specialization) base class which ProxyServer classes produced by generated code will inherit from.

The default specialization of this class just inherits from ProxyServerBase, but custom specializations can be defined to control ProxyServer behavior.

Specifically, it can be useful to specialize this class to add additional state to ProxyServer classes, for example to cache state between IPC calls. If this is done, however, care should be taken to ensure that the extra state can be destroyed without blocking, because ProxyServer destructors are called from the EventLoop thread, and if they block, it could deadlock the program. One way to do avoid blocking is to clean up the state by pushing cleanup callbacks to the m_context.cleanup_fns list, which run after the server m_impl object is destroyed on the same thread destroying it (which will either be an IPC worker thread if the ProxyServer is being explicitly destroyed by a client calling a destroy() method with a Context argument and Context.thread value set, or the temporary EventLoop::m_async_thread used to run destructors without blocking the event loop when no-longer used server objects are garbage collected by Cap'n Proto.) Alternately, if cleanup needs to run before m_impl is destroyed, the specialization can override invokeDestroy and destructor methods to do that.

Definition at line 168 of file proxy.h.


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