yanglimingcn commented on code in PR #2920: URL: https://github.com/apache/brpc/pull/2920#discussion_r2005005094
########## src/brpc/rdma/rdma_endpoint.cpp: ########## @@ -1486,6 +1527,88 @@ void RdmaEndpoint::GlobalRelease() { delete res; } } + + if (FLAGS_rdma_use_polling) { + PollingModeRelease(); + } +} + +std::vector<RdmaEndpoint::Poller> RdmaEndpoint::_pollers; +std::atomic<bool> RdmaEndpoint::_running(false); + +void RdmaEndpoint::SetCallbackFn(std::function<void()> cb) { + for (int i = 0; i < FLAGS_rdma_poller_num; ++i) { + auto& poller = _pollers[i]; + std::unique_lock<bthread::Mutex> lk(poller.callback_mutex); + poller.callback = cb; + } +} + +int RdmaEndpoint::PollingModeInitialize() { + auto fn = [](void* args) -> void* { + auto poller = static_cast<Poller*>(args); + while (_running.load(butil::memory_order_relaxed)) { + std::list<Socket*> sockets; + { + std::unique_lock<bthread::Mutex> lk(poller->sockets_mutex); + sockets = poller->sockets; // copy all sockets is not good + } + for (auto m : sockets) { + PollCq(m); + } + { + std::unique_lock<bthread::Mutex> lk(poller->callback_mutex); + if (poller->callback) { Review Comment: 用户设置callback的时间点很可能在rdma环境都初始化完了之后,所以得加锁保护一下。 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org