PIHTTP::MessageConst code categories
PIHTTPClient migrated to curl_multi_api
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <curl/curl.h>
|
||||
|
||||
CurlThreadPool::CurlThreadPool() {
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
piForTimes(10) {
|
||||
auto * t = new PIThread([this]() { threadFunc(); }, true);
|
||||
threads << t;
|
||||
@@ -15,27 +16,10 @@ CurlThreadPool::CurlThreadPool() {
|
||||
|
||||
|
||||
CurlThreadPool::~CurlThreadPool() {
|
||||
exiting = true;
|
||||
for (auto * t: threads)
|
||||
t->stop();
|
||||
{
|
||||
auto cr = clients.getRef();
|
||||
for (auto c: *cr)
|
||||
c->abort();
|
||||
}
|
||||
sem.release(threads.size());
|
||||
for (auto * t: threads) {
|
||||
t->waitForFinish();
|
||||
t->setDebug(false);
|
||||
t->terminate();
|
||||
}
|
||||
piDeleteAllAndClear(threads);
|
||||
{
|
||||
auto cr = clients.getRef();
|
||||
for (auto c: *cr)
|
||||
delete c;
|
||||
}
|
||||
destroy();
|
||||
// piCout << "~CurlThreadPool cleanup ...";
|
||||
curl_global_cleanup();
|
||||
// piCout << "~CurlThreadPool cleanup ok";
|
||||
}
|
||||
|
||||
|
||||
@@ -75,3 +59,30 @@ CurlThreadPool * CurlThreadPool::instance() {
|
||||
static CurlThreadPool ret;
|
||||
return &ret;
|
||||
}
|
||||
|
||||
void CurlThreadPool::destroy() {
|
||||
// piCout << "~CurlThreadPool";
|
||||
exiting = true;
|
||||
for (auto * t: threads)
|
||||
t->stop();
|
||||
{
|
||||
auto cr = clients.getRef();
|
||||
for (auto c: *cr)
|
||||
c->abort();
|
||||
}
|
||||
// piCout << "~CurlThreadPool release ...";
|
||||
sem.release(threads.size());
|
||||
for (auto * t: threads) {
|
||||
t->waitForFinish();
|
||||
t->setDebug(false);
|
||||
t->terminate();
|
||||
}
|
||||
// piCout << "~CurlThreadPool delete ...";
|
||||
piDeleteAllAndClear(threads);
|
||||
{
|
||||
auto cr = clients.getRef();
|
||||
for (auto c: *cr)
|
||||
delete c;
|
||||
}
|
||||
// piCout << "~CurlThreadPool ok";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user