lib/curl/Request: add methods StartIndirect(), StopIndirect()

This commit is contained in:
Max Kellermann 2018-01-11 20:50:16 +01:00
parent 55d1473918
commit edcd0b9913
2 changed files with 27 additions and 0 deletions

View File

@ -32,6 +32,7 @@
#include "Global.hxx" #include "Global.hxx"
#include "Version.hxx" #include "Version.hxx"
#include "Handler.hxx" #include "Handler.hxx"
#include "event/Call.hxx"
#include "util/RuntimeError.hxx" #include "util/RuntimeError.hxx"
#include "util/StringStrip.hxx" #include "util/StringStrip.hxx"
#include "util/StringView.hxx" #include "util/StringView.hxx"
@ -80,6 +81,14 @@ CurlRequest::Start()
registered = true; registered = true;
} }
void
CurlRequest::StartIndirect()
{
BlockingCall(global.GetEventLoop(), [this](){
Start();
});
}
void void
CurlRequest::Stop() noexcept CurlRequest::Stop() noexcept
{ {
@ -90,6 +99,14 @@ CurlRequest::Stop() noexcept
registered = false; registered = false;
} }
void
CurlRequest::StopIndirect()
{
BlockingCall(global.GetEventLoop(), [this](){
Stop();
});
}
void void
CurlRequest::FreeEasy() noexcept CurlRequest::FreeEasy() noexcept
{ {

View File

@ -93,6 +93,11 @@ public:
*/ */
void Start(); void Start();
/**
* A thread-safe version of Start().
*/
void StartIndirect();
/** /**
* Unregister this request via CurlGlobal::Remove(). * Unregister this request via CurlGlobal::Remove().
* *
@ -100,6 +105,11 @@ public:
*/ */
void Stop() noexcept; void Stop() noexcept;
/**
* A thread-safe version of Stop().
*/
void StopIndirect();
CURL *Get() noexcept { CURL *Get() noexcept {
return easy.Get(); return easy.Get();
} }