]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/asio/impl/thread_pool.ipp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / asio / impl / thread_pool.ipp
index e0952eb657e222838c8e6e735dd6b16f42e44b48..d59b6ef15f15716efe3359b255bb08906d2e885d 100644 (file)
@@ -2,7 +2,7 @@
 // impl/thread_pool.ipp
 // ~~~~~~~~~~~~~~~~~~~~
 //
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -35,7 +35,7 @@ struct thread_pool::thread_function
 };
 
 thread_pool::thread_pool()
-  : scheduler_(use_service<detail::scheduler>(*this))
+  : scheduler_(add_scheduler(new detail::scheduler(*this, 0, false)))
 {
   scheduler_.work_started();
 
@@ -45,7 +45,8 @@ thread_pool::thread_pool()
 }
 
 thread_pool::thread_pool(std::size_t num_threads)
-  : scheduler_(use_service<detail::scheduler>(*this))
+  : scheduler_(add_scheduler(new detail::scheduler(
+          *this, num_threads == 1 ? 1 : 0, false)))
 {
   scheduler_.work_started();
 
@@ -66,8 +67,18 @@ void thread_pool::stop()
 
 void thread_pool::join()
 {
-  scheduler_.work_finished();
-  threads_.join();
+  if (!threads_.empty())
+  {
+    scheduler_.work_finished();
+    threads_.join();
+  }
+}
+
+detail::scheduler& thread_pool::add_scheduler(detail::scheduler* s)
+{
+  detail::scoped_ptr<detail::scheduler> scoped_impl(s);
+  boost::asio::add_service<detail::scheduler>(*this, scoped_impl.get());
+  return *scoped_impl.release();
 }
 
 } // namespace asio