-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
brpcServer 异步处理 #2446
Comments
看下这个#2328 满足需求吗 |
那么是在Echo 处理函数中回复了Echo response,同时启动一个线程来运行你的业务函数就行了吧 |
想了解brpc有没有预留这样的借口,自己起线程,感觉在程序退出时,可能会有资源访问core问题 |
谢谢 我学习一下 |
运行done->Run()后request和response都会被析构,如果在单独业务线程中会访问req和resp会有问题 |
Hi,如果是这样,你应该拓展done的生命周期,类似这样: void ChatServiceImpl::Syn(google::protobuf::RpcController *cntl_base,
const HttpRequest *, HttpResponse *,
google::protobuf::Closure *done) {
brpc::ClosureGuard done_guard(done);
brpc::Controller *cntl = static_cast<brpc::Controller *>(cntl_base);
auto job = std::make_shared<Asyncjob>();
...
job->cntl = cntl;
job->done = done_guard.release();
infer_job_scheduler_->noNewJob(job);
...
}
|
用echo.proto中的Echo举例,我的需求是,在Echo()运行完后,server能够直接运行一个业务函数,求各位大佬多多指教
The text was updated successfully, but these errors were encountered: