Closed zhangyachen closed 3 months ago
你通过future.get()的方式本质上还是阻塞当前线程来等待结果,那么使用异步接口就意义不大了。你可以不使用future.get(),而是在TRITONSERVER_InferenceRequestSetResponseCallback 设置的callback函数中调用done->Run()来发送回复。 这样的话,使用bthread_start_background来启动新线程也是没有必要的,因为新线程里只是发起了一个异步请求。所以,可以直接在SayHello里面同步调用process_thread方法。
好的,我想再确认一下您的建议:
期待您的回复。 ^_^
好的,我想再确认一下您的建议:
- SayHello中直接调用 process_thread函数。
- process_thread中也没有必要进行promise和future的操作。
- TRITONSERVER_InferenceRequestSetResponseCallback中捕获done,,callback收到response后在done->Run()。
期待您的回复。 ^_^
是的
Is your feature request related to a problem? (你需要的功能是否与某个问题有关?) 我正在从grpc切换到brpc框架,想请教一下brpc异步server的使用方式问题。
背景:
在我们需要实现rpc server接口中,会调用一个异步接口async(),调用后立即返回。 当async背后的逻辑处理完成,会调用提前设置好的callback。从调用async到再调用callback大概10ms。
Describe the solution you'd like (描述你期望的解决方法) 在之前grpc中使用的异步处理,利用ServerCompletionQueue结构。 我想请教一下,在brpc中,如果使用异步接口,内部再调用另外一个异步接口async,有什么最佳实践吗? 我想到的是在调用async后使用future.get(),在callback中set_value。不知道这种方式在brpc异步接口中是否会有什么性能问题和额外考虑的问题?
谢谢。
Describe alternatives you've considered (描述你想到的折衷方案)
Additional context/screenshots (更多上下文/截图) 打算实现的简单伪代码,主要逻辑在AsyncInferJob::run():