Browse Source

Updated README

yhirose 6 years ago
parent
commit
e383b277a4
1 changed files with 40 additions and 0 deletions
  1. 40 0
      README.md

+ 40 - 0
README.md

@@ -117,6 +117,46 @@ svr.Get("/chunked", [&](const Request& req, Response& res) {
 });
 });
 ```
 ```
 
 
+### Default thread pool supporet
+
+Set thread count to 8:
+
+```cpp
+#define CPPHTTPLIB_THREAD_POOL_COUNT 8
+```
+
+Disable the default thread pool:
+
+```cpp
+#define CPPHTTPLIB_THREAD_POOL_COUNT 0
+```
+
+### Override the default thread pool with yours
+
+```cpp
+class YourThreadPoolTaskQueue : public TaskQueue {
+public:
+  YourThreadPoolTaskQueue(size_t n) {
+    pool_.start_with_thread_count(n);
+  }
+
+  virtual void enqueue(std::function<void()> fn) override {
+    pool_.enqueue(fn);
+  }
+
+  virtual void shutdown() override {
+    pool_.shutdown_gracefully();
+  }
+
+private:
+  YourThreadPool pool_;
+};
+
+svr.new_task_queue = [] {
+  return new YourThreadPoolTaskQueue(12);
+};
+```
+
 Client Example
 Client Example
 --------------
 --------------