@@ -98,13 +98,6 @@ void CustomBuildField(TypeList<>,
98
98
context.setCallbackThread (callback_thread->second .m_client );
99
99
}
100
100
101
- // Invoke promise1, then promise2, and return result of promise2.
102
- template <typename T, typename U>
103
- kj::Promise<U> JoinPromises (kj::Promise<T>&& prom1, kj::Promise<U>&& prom2)
104
- {
105
- return prom1.then ([prom2 = kj::mv (prom2)]() mutable { return kj::mv (prom2); });
106
- }
107
-
108
101
// ! PassField override for mp.Context arguments. Return asynchronously and call
109
102
// ! function on other thread found in context.
110
103
template <typename Accessor, typename ServerContext, typename Fn, typename ... Args>
@@ -181,27 +174,24 @@ auto PassField(Priority<1>, TypeList<>, ServerContext& server_context, const Fn&
181
174
// be a local Thread::Server object, but it needs to be looked up
182
175
// asynchronously with getLocalServer().
183
176
auto thread_client = context_arg.getThread ();
184
- return JoinPromises (server.m_context .connection ->m_threads .getLocalServer (thread_client)
185
- .then ([&server, invoke, req](const kj::Maybe<Thread::Server&>& perhaps) {
186
- // Assuming the thread object is found, pass it a pointer to the
187
- // `invoke` lambda above which will invoke the function on that
188
- // thread.
189
- KJ_IF_MAYBE (thread_server, perhaps)
190
- {
191
- const auto & thread = static_cast <ProxyServer<Thread>&>(*thread_server);
192
- server.m_context .connection ->m_loop .log () << " IPC server post request #" << req << " {"
193
- << thread.m_thread_context .thread_name << " }" ;
194
- thread.m_thread_context .waiter ->post (std::move (invoke));
195
- }
196
- else
197
- {
198
- server.m_context .connection ->m_loop .log () << " IPC server error request #" << req
199
- << " , missing thread to execute request" ;
200
- throw std::runtime_error (" invalid thread handle" );
201
- }
202
- }),
177
+ return server.m_context .connection ->m_threads .getLocalServer (thread_client)
178
+ .then ([&server, invoke, req](const kj::Maybe<Thread::Server&>& perhaps) {
179
+ // Assuming the thread object is found, pass it a pointer to the
180
+ // `invoke` lambda above which will invoke the function on that
181
+ // thread.
182
+ KJ_IF_MAYBE (thread_server, perhaps) {
183
+ const auto & thread = static_cast <ProxyServer<Thread>&>(*thread_server);
184
+ server.m_context .connection ->m_loop .log ()
185
+ << " IPC server post request #" << req << " {" << thread.m_thread_context .thread_name << " }" ;
186
+ thread.m_thread_context .waiter ->post (std::move (invoke));
187
+ } else {
188
+ server.m_context .connection ->m_loop .log ()
189
+ << " IPC server error request #" << req << " , missing thread to execute request" ;
190
+ throw std::runtime_error (" invalid thread handle" );
191
+ }
192
+ })
203
193
// Wait for the invocation to finish before returning to the caller.
204
- kj::mv (future.promise ));
194
+ . then ([invoke_wait = kj::mv (future.promise )]() mutable { return kj::mv (invoke_wait); } );
205
195
}
206
196
207
197
// Destination parameter type that can be passed to ReadField function as an
0 commit comments