yanglimingcn commented on code in PR #2920:
URL: https://github.com/apache/brpc/pull/2920#discussion_r2003011966


##########
src/brpc/rdma/rdma_endpoint.cpp:
##########
@@ -1486,6 +1527,84 @@ void RdmaEndpoint::GlobalRelease() {
             delete res;
         }
     }
+
+    if (FLAGS_rdma_use_polling) {
+        PollingModeRelease();
+    }
+}
+
+std::vector<RdmaEndpoint::Poller> RdmaEndpoint::_pollers;
+std::atomic<bool> RdmaEndpoint::_running(false);
+std::function<void()> RdmaEndpoint::_callback(nullptr);
+butil::Mutex RdmaEndpoint::_cb_mutex;
+
+void RdmaEndpoint::SetCallbackFn(std::function<void()> cb) { _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<butil::Mutex> lk(poller->mutex);
+                sockets = poller->sockets;  // copy all sockets is not good
+            }
+            for (auto m : sockets) {
+                PollCq(m);
+            }
+            {
+                std::unique_lock<butil::Mutex> lk(_cb_mutex);
+                if (_callback) {
+                    _callback();

Review Comment:
   这个肯定不是频繁设置的,一般是在程序初始化的时候,设置一个spdk的收割逻辑的function,所以平时应该不需要设置。
   不过我知道你的点了,多个core的时候还是会竞争这个锁,这是不对的。



-- 
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

Reply via email to