]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/msg/QueueStrategy.cc
update sources to v12.1.1
[ceph.git] / ceph / src / msg / QueueStrategy.cc
index 0ce279b31e9f1055abd6b79545a53df6d76a840e..e41ab79fdeb34671ea4a954d8a4f4d3022030dac 100644 (file)
@@ -15,6 +15,7 @@
 #include "QueueStrategy.h"
 #define dout_subsys ceph_subsys_ms
 #include "common/debug.h"
+#include "common/backport14.h"
 
 QueueStrategy::QueueStrategy(int _n_threads)
   : lock("QueueStrategy::lock"),
@@ -85,16 +86,13 @@ void QueueStrategy::shutdown()
 
 void QueueStrategy::wait()
 {
-  QSThread *thrd;
   lock.Lock();
   assert(stop);
-  while (disp_threads.size()) {
-    thrd = &(disp_threads.front());
-    disp_threads.pop_front();
+  for (auto& thread : threads) {
     lock.Unlock();
 
     // join outside of lock
-    thrd->join();
+    thread->join();
 
     lock.Lock();
   }
@@ -103,14 +101,15 @@ void QueueStrategy::wait()
 
 void QueueStrategy::start()
 {
-  QSThread *thrd;
   assert(!stop);
   lock.Lock();
+  threads.reserve(n_threads);
   for (int ix = 0; ix < n_threads; ++ix) {
     string thread_name = "ms_xio_qs_";
     thread_name.append(std::to_string(ix));
-    thrd = new QSThread(this);
+    auto thrd = ceph::make_unique<QSThread>(this);
     thrd->create(thread_name.c_str());
+    threads.emplace_back(std::move(thrd));
   }
   lock.Unlock();
 }