@@ -60,8 +60,35 @@ class ProxyClientBase : public Impl_
60
60
ProxyClientBase (typename Interface::Client client, Connection* connection, bool destroy_connection);
61
61
~ProxyClientBase () noexcept ;
62
62
63
- // Methods called during client construction/destruction that can optionally
64
- // be defined in capnp interface to trigger the server.
63
+ // construct/destroy methods called during client construction/destruction
64
+ // that can optionally be defined in capnp interfaces to invoke code on the
65
+ // server when proxy client objects are created and destroyed.
66
+ //
67
+ // The construct() method is not generally very useful, but can be used to
68
+ // run custom code on the server automatically when a ProxyClient client is
69
+ // constructed. The only current use is adding a construct method to Init
70
+ // interfaces that is called automatically on construction, so client and
71
+ // server exchange ThreadMap references and set Connection::m_thread_map
72
+ // values as soon as the Init client is created.
73
+ //
74
+ // construct @0 (threadMap: Proxy.ThreadMap) -> (threadMap: Proxy.ThreadMap);
75
+ //
76
+ // But construct() is not necessary for this, thread maps could be passed
77
+ // through a normal method that is just called explicitly rather than
78
+ // implicitly.
79
+ //
80
+ // The destroy() method is more generally useful than construct(), because
81
+ // it ensures that the server object will be destroyed synchronously before
82
+ // the client destructor returns, instead of asynchronously at some
83
+ // unpredictable time after the client object is already destroyed and
84
+ // client code has moved on. If the destroy method accepts a Context
85
+ // parameter like:
86
+ //
87
+ // destroy @0 (context: Proxy.Context) -> ();
88
+ //
89
+ // then it will also ensure that the destructor runs on the same thread the
90
+ // client used to make other RPC calls, instead of running on the server
91
+ // EventLoop thread and possibly blocking it.
65
92
void construct () {}
66
93
void destroy () {}
67
94
0 commit comments