From e383b277a45278feaba0b762713f7c80dc0e7c87 Mon Sep 17 00:00:00 2001 From: yhirose Date: Mon, 5 Aug 2019 18:17:40 +0900 Subject: [PATCH] Updated README --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/README.md b/README.md index 3c48097..8898532 100644 --- a/README.md +++ b/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 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 --------------