File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -435,7 +435,7 @@ class ThreadPool : public TaskQueue {
435
435
std::condition_variable cond_;
436
436
std::mutex mutex_;
437
437
};
438
- #else
438
+ #elif CPPHTTPLIB_THREAD_POOL_COUNT == 0
439
439
class Threads : public TaskQueue {
440
440
public:
441
441
Threads () : running_threads_(0 ) {}
@@ -469,6 +469,19 @@ class Threads : public TaskQueue {
469
469
std::mutex running_threads_mutex_;
470
470
int running_threads_;
471
471
};
472
+ #else
473
+ class NoThread : public TaskQueue {
474
+ public:
475
+ NoThread () {}
476
+ virtual ~NoThread () {}
477
+
478
+ virtual void enqueue (std::function<void ()> fn) override {
479
+ fn ();
480
+ }
481
+
482
+ virtual void shutdown () override {
483
+ }
484
+ };
472
485
#endif
473
486
474
487
class Server {
@@ -2335,8 +2348,10 @@ inline Server::Server()
2335
2348
new_task_queue = [] {
2336
2349
#if CPPHTTPLIB_THREAD_POOL_COUNT > 0
2337
2350
return new ThreadPool (CPPHTTPLIB_THREAD_POOL_COUNT);
2338
- #else
2351
+ #elif CPPHTTPLIB_THREAD_POOL_COUNT == 0
2339
2352
return new Threads ();
2353
+ #else
2354
+ return new NoThread ();
2340
2355
#endif
2341
2356
};
2342
2357
}
You can’t perform that action at this time.
0 commit comments