Skip to content

Commit e49a925

Browse files
committed
doc: Add comments to mp.Context PassField function on mp.Context.thread lookup
1 parent e29f74e commit e49a925

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
@@ -157,9 +157,15 @@ auto PassField(Priority<1>, TypeList<>, ServerContext& server_context, const Fn&
157157
}
158158
});
159159

160+
// Lookup Thread object specified by the client. The specified thread should
161+
// be a local Thread::Server object, but it needs to be looked up
162+
// asynchronously with getLocalServer().
160163
auto thread_client = context_arg.getThread();
161164
return JoinPromises(server.m_context.connection->m_threads.getLocalServer(thread_client)
162165
.then([&server, invoke, req](const kj::Maybe<Thread::Server&>& perhaps) {
166+
// Assuming the thread object is found, pass it a pointer to the
167+
// `invoke` lambda above which will invoke the function on that
168+
// thread.
163169
KJ_IF_MAYBE(thread_server, perhaps)
164170
{
165171
const auto& thread = static_cast<ProxyServer<Thread>&>(*thread_server);
@@ -174,6 +180,7 @@ auto PassField(Priority<1>, TypeList<>, ServerContext& server_context, const Fn&
174180
throw std::runtime_error("invalid thread handle");
175181
}
176182
}),
183+
// Wait for the invocation to finish before returning to the caller.
177184
kj::mv(future.promise));
178185
}
179186

0 commit comments

Comments
 (0)