Default thread pool supportThreadPool is used as a default task queue, and the default thread count is 8, or std::thread::hardware_concurrency(). You can change it with CPPHTTPLIB_THREAD_POOL_COUNT.If you want to set the thread count at runtime, there is no convenient way... But ...
classYourThreadPoolTaskQueue:publicTaskQueue {public: YourThreadPoolTaskQueue(size_tn) { pool_.start_with_thread_count(n); }virtualvoidenqueue(std::function<void()> fn)override{ pool_.enqueue(fn); }virtualvoidshutdown()override{ pool_.shutdown_gracefully(); }private: YourThreadPool pool_; ...
Override the default thread pool with yours classYourThreadPoolTaskQueue:publicTaskQueue{public:YourThreadPoolTaskQueue(size_tn) { pool_.start_with_thread_count(n); }virtualvoidenqueue(std::function<void()> fn)override{ pool_.enqueue(fn); }virtualvoidshutdown()override{ pool_.shutdown_gracefull...
TaskQueue(size_tn) { pool_.start_with_thread_count(n); }virtualvoidenqueue(std::function<void()> fn)override{ pool_.enqueue(fn); }virtualvoidshutdown()override{ pool_.shutdown_gracefully(); }private:YourThreadPool pool_; }; svr.new_task_queue = [] {returnnewYourThreadPoolTaskQueue(...
pool_.start_with_thread_count(n); }virtualvoidenqueue(std::function<void()> fn)override{ pool_.enqueue(fn); }virtualvoidshutdown()override{ pool_.shutdown_gracefully(); }private: YourThreadPool pool_; }; svr.new_task_queue = [] {returnnewYourThreadPoolTaskQueue(12); ...
class YourThreadPoolTaskQueue : public TaskQueue { public: YourThreadPoolTaskQueue(size_t n) { pool_.start_with_thread_count(n); } virtual bool enqueue(std::function<void()> fn) override { /* Return true if the task was actually enqueued, or false * if the caller must drop the ...
{ 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...
start_with_thread_count(n); } virtual bool enqueue(std::function<void()> fn) override { /* Return true if the task was actually enqueued, or false * if the caller must drop the corresponding connection. */ return pool_.enqueue(fn); } virtual void shutdown() override { pool_.shut...
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); }...
ThreadPool is used as the default task queue, with a default thread count of 8 or std::thread::hardware_concurrency() - 1, whichever is greater. You can change it with CPPHTTPLIB_THREAD_POOL_COUNT. If you want to set the thread count at runtime, there is no convenient way... But ...