So far, I've been successful in pulling information from a service provider. However, I need to invoke this over parallel process with multiple threads for millions of requests.
Following is the piece of code
size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
int main()
{
CURL *curl = curl_easy_init();
std::string readBuffer;
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "service-url");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}
Here are my two options a) One is thread pool (Visual studio C++ 2010 - Thus no access to C++ 11) b) Using curl_multi_perform
When I use thread pool -> Does invoking curl become a worker thread. How do I make user that the WriteCallback is specific to the thread so that no two threads overwrite the contents.
If I use curl_multi_perform, what do I need to do, to make sure that WriteCallback gives me the output for that particular handle?