Added NoThread task queue
This commit is contained in:
parent
94d13e88a5
commit
d45676b064
19
httplib.h
19
httplib.h
@ -435,7 +435,7 @@ private:
|
|||||||
std::condition_variable cond_;
|
std::condition_variable cond_;
|
||||||
std::mutex mutex_;
|
std::mutex mutex_;
|
||||||
};
|
};
|
||||||
#else
|
#elif CPPHTTPLIB_THREAD_POOL_COUNT == 0
|
||||||
class Threads : public TaskQueue {
|
class Threads : public TaskQueue {
|
||||||
public:
|
public:
|
||||||
Threads() : running_threads_(0) {}
|
Threads() : running_threads_(0) {}
|
||||||
@ -469,6 +469,19 @@ private:
|
|||||||
std::mutex running_threads_mutex_;
|
std::mutex running_threads_mutex_;
|
||||||
int running_threads_;
|
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
|
#endif
|
||||||
|
|
||||||
class Server {
|
class Server {
|
||||||
@ -2335,8 +2348,10 @@ inline Server::Server()
|
|||||||
new_task_queue = [] {
|
new_task_queue = [] {
|
||||||
#if CPPHTTPLIB_THREAD_POOL_COUNT > 0
|
#if CPPHTTPLIB_THREAD_POOL_COUNT > 0
|
||||||
return new ThreadPool(CPPHTTPLIB_THREAD_POOL_COUNT);
|
return new ThreadPool(CPPHTTPLIB_THREAD_POOL_COUNT);
|
||||||
#else
|
#elif CPPHTTPLIB_THREAD_POOL_COUNT == 0
|
||||||
return new Threads();
|
return new Threads();
|
||||||
|
#else
|
||||||
|
return new NoThread();
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user