#ifndef curl_thread_pool_p_H
#define curl_thread_pool_p_H

#include "piprotectedvariable.h"
#include "pisemaphore.h"
#include "pithread.h"

class PIHTTPClient;

class CurlThreadPool {
public:
	void registerClient(PIHTTPClient * c);

	static CurlThreadPool * instance();

private:
	NO_COPY_CLASS(CurlThreadPool)
	CurlThreadPool();
	~CurlThreadPool();

	void destroy();
	void threadFunc();
	void procClient(PIHTTPClient * c);

	PIProtectedVariable<PIQueue<PIHTTPClient *>> clients;
	PIProtectedVariable<PIVector<PIHTTPClient *>> clients_in_proc;
	PISemaphore sem;
	PIVector<PIThread *> threads;
	std::atomic_bool exiting = {false};
};


#endif
