mirror of
https://github.com/yhirose/cpp-httplib
synced 2024-11-21 14:29:10 -07:00
Added NoThread task queue
This commit is contained in:
parent
94d13e88a5
commit
d45676b064
1 changed files with 17 additions and 2 deletions
19
httplib.h
19
httplib.h
|
@ -435,7 +435,7 @@ private:
|
|||
std::condition_variable cond_;
|
||||
std::mutex mutex_;
|
||||
};
|
||||
#else
|
||||
#elif CPPHTTPLIB_THREAD_POOL_COUNT == 0
|
||||
class Threads : public TaskQueue {
|
||||
public:
|
||||
Threads() : running_threads_(0) {}
|
||||
|
@ -469,6 +469,19 @@ private:
|
|||
std::mutex running_threads_mutex_;
|
||||
int running_threads_;
|
||||
};
|
||||
#else
|
||||
class NoThread : public TaskQueue {
|
||||
public:
|
||||
NoThread() {}
|
||||
virtual ~NoThread() {}
|
||||
|
||||
virtual void enqueue(std::function<void()> fn) override {
|
||||
fn();
|
||||
}
|
||||
|
||||
virtual void shutdown() override {
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
class Server {
|
||||
|
@ -2335,8 +2348,10 @@ inline Server::Server()
|
|||
new_task_queue = [] {
|
||||
#if CPPHTTPLIB_THREAD_POOL_COUNT > 0
|
||||
return new ThreadPool(CPPHTTPLIB_THREAD_POOL_COUNT);
|
||||
#else
|
||||
#elif CPPHTTPLIB_THREAD_POOL_COUNT == 0
|
||||
return new Threads();
|
||||
#else
|
||||
return new NoThread();
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue