lib/curl/Request: require the caller to explicitly register the request
This allows constructing an instance in any thread, and register it inside the IOThread later.
This commit is contained in:
@@ -58,7 +58,12 @@ class CurlRequest {
|
||||
/** error message provided by libcurl */
|
||||
char error_buffer[CURL_ERROR_SIZE];
|
||||
|
||||
bool registered = false;
|
||||
|
||||
public:
|
||||
/**
|
||||
* To start sending the request, call Start().
|
||||
*/
|
||||
CurlRequest(CurlGlobal &_global, const char *url,
|
||||
CurlResponseHandler &_handler);
|
||||
~CurlRequest();
|
||||
@@ -66,6 +71,21 @@ public:
|
||||
CurlRequest(const CurlRequest &) = delete;
|
||||
CurlRequest &operator=(const CurlRequest &) = delete;
|
||||
|
||||
/**
|
||||
* Register this request via CurlGlobal::Add(), which starts
|
||||
* the request.
|
||||
*
|
||||
* This method must be called in the event loop thread.
|
||||
*/
|
||||
void Start();
|
||||
|
||||
/**
|
||||
* Unregister this request via CurlGlobal::Remove().
|
||||
*
|
||||
* This method must be called in the event loop thread.
|
||||
*/
|
||||
void Stop();
|
||||
|
||||
CURL *Get() {
|
||||
return easy.Get();
|
||||
}
|
||||
|
Reference in New Issue
Block a user