mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-10 21:09:38 +01:00
Removed RequestPool.
This commit is contained in:
parent
8211115346
commit
6b29462503
@ -114,62 +114,4 @@ protected:
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user