Bump version to 52:0
[folly.git] / folly / wangle / bootstrap / ServerBootstrap.h
index 4940e67b504509b571c7e73e1c3cf5af0b76910a..2c2a6b47dcafd5b0f2ad13f3a046c8789b173587 100644 (file)
@@ -45,7 +45,7 @@ class ServerBootstrap {
   ServerBootstrap(const ServerBootstrap& that) = delete;
   ServerBootstrap(ServerBootstrap&& that) = default;
 
-  ServerBootstrap() {}
+  ServerBootstrap() = default;
 
   ~ServerBootstrap() {
     stop();
@@ -120,8 +120,13 @@ class ServerBootstrap {
         1, std::make_shared<wangle::NamedThreadFactory>("Acceptor Thread"));
     }
     if (!io_group) {
+      auto threads = std::thread::hardware_concurrency();
+      if (threads <= 0) {
+        // Reasonable mid-point for concurrency when actual value unknown
+        threads = 8;
+      }
       io_group = std::make_shared<folly::wangle::IOThreadPoolExecutor>(
-        32, std::make_shared<wangle::NamedThreadFactory>("IO Thread"));
+        threads, std::make_shared<wangle::NamedThreadFactory>("IO Thread"));
     }
 
     // TODO better config checking