Removed RequestPool.

This commit is contained in:
Relintai 2022-06-26 11:09:36 +02:00
parent 8211115346
commit 6b29462503

View File

@ -114,62 +114,4 @@ protected:
uint32_t _path_stack_pointer; uint32_t _path_stack_pointer;
}; };
template <class T>
class WebServerRequestPool {
public:
T *get_request();
void return_request(T *request);
WebServerRequestPool();
~WebServerRequestPool();
protected:
std::mutex _mutex;
std::vector<T *> _requests;
};
template <class T>
T *WebServerRequestPool<T>::get_request() {
_mutex.lock();
T *request;
if (_requests.size() == 0) {
_mutex.unlock();
request = new T();
return request;
}
request = _requests[_requests.size() - 1];
_requests.pop_back();
_mutex.unlock();
request->reset();
return request;
}
template <class T>
void WebServerRequestPool<T>::return_request(T *request) {
_mutex.lock();
_requests.push_back(request);
_mutex.unlock();
}
template <class T>
WebServerRequestPool<T>::WebServerRequestPool() {
}
template <class T>
WebServerRequestPool<T>::~WebServerRequestPool() {
for (uint32_t i = 0; i < _requests.size(); ++i) {
delete _requests[i];
}
_requests.clear();
}
#endif #endif