Skip to content

Commit 2098ae1

Browse files
committed
doc: Add comment on serverInvoke ReplaceVoid usage
1 parent a1dfb0b commit 2098ae1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/mp/proxy-types.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,13 @@ kj::Promise<void> serverInvoke(Server& server, CallContext& call_context, Fn fn)
15531553
using ServerContext = ServerInvokeContext<Server, CallContext>;
15541554
using ArgList = typename ProxyClientMethodTraits<typename Params::Reads>::Params;
15551555
ServerContext server_context{server, call_context, req};
1556+
// ReplaceVoid is used to support fn.invoke implementations that
1557+
// execute asynchronously and return promises, as well as
1558+
// implementations that execute synchronously and return void. The
1559+
// invoke function will be synchronous by default, but asynchronous if
1560+
// an mp.Context argument is passed, and the mp.Context PassField
1561+
// overload returns a promise executing the request in a worker thread
1562+
// and waiting for it to complete.
15561563
return ReplaceVoid([&]() { return fn.invoke(server_context, ArgList()); },
15571564
[&]() { return kj::Promise<CallContext>(kj::mv(call_context)); })
15581565
.then([&server, req](CallContext call_context) {

0 commit comments

Comments
 (0)