]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
async/Stack: pass Worker* to NetworkStack::add_thread()
authorKefu Chai <kchai@redhat.com>
Wed, 24 Feb 2021 04:43:52 +0000 (12:43 +0800)
committeryite.gu <yitegu0@gmail.com>
Sun, 4 Feb 2024 03:22:27 +0000 (11:22 +0800)
so we don't need to pass worker id to it.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 2d6988feabd8759fc77088b0e0e49cbf8c360602)

src/msg/async/Stack.cc
src/msg/async/Stack.h

index 37e15634d79c02f9724dad7dcf22a2914b540af0..177a7148cff95df14148510cd6cbb93a25f695bd 100644 (file)
@@ -34,9 +34,8 @@
 #undef dout_prefix
 #define dout_prefix *_dout << "stack "
 
-std::function<void ()> NetworkStack::add_thread(unsigned worker_id)
+std::function<void ()> NetworkStack::add_thread(Worker* w)
 {
-  Worker *w = workers[worker_id];
   return [this, w]() {
       char tp_name[16];
       sprintf(tp_name, "msgr-worker-%u", w->id);
@@ -122,10 +121,10 @@ void NetworkStack::start()
   }
 
   for (unsigned i = 0; i < num_workers; ++i) {
-    if (workers[i]->is_init())
+    Worker* worker = workers[i];
+    if (worker->is_init())
       continue;
-    std::function<void ()> thread = add_thread(i);
-    spawn_worker(i, std::move(thread));
+    spawn_worker(add_thread(worker));
   }
   started = true;
   lk.unlock();
index 6a2188b5a9c7921a5d152cee5c9103afa54677f3..c5114ce37d0e0adfdb3c51f655ed0ae0d6814614 100644 (file)
@@ -297,7 +297,7 @@ class NetworkStack {
   ceph::spinlock pool_spin;
   bool started = false;
 
-  std::function<void ()> add_thread(unsigned i);
+  std::function<void ()> add_thread(Worker* w);
 
   virtual Worker* create_worker(CephContext *c, unsigned i) = 0;