Commit edcd0b99 authored by Max Kellermann's avatar Max Kellermann

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

parent 55d14739
...@@ -32,6 +32,7 @@ ...@@ -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"
...@@ -81,6 +82,14 @@ CurlRequest::Start() ...@@ -81,6 +82,14 @@ CurlRequest::Start()
} }
void void
CurlRequest::StartIndirect()
{
BlockingCall(global.GetEventLoop(), [this](){
Start();
});
}
void
CurlRequest::Stop() noexcept CurlRequest::Stop() noexcept
{ {
if (!registered) if (!registered)
...@@ -91,6 +100,14 @@ CurlRequest::Stop() noexcept ...@@ -91,6 +100,14 @@ CurlRequest::Stop() noexcept
} }
void void
CurlRequest::StopIndirect()
{
BlockingCall(global.GetEventLoop(), [this](){
Stop();
});
}
void
CurlRequest::FreeEasy() noexcept CurlRequest::FreeEasy() noexcept
{ {
if (!easy) if (!easy)
......
...@@ -94,12 +94,22 @@ public: ...@@ -94,12 +94,22 @@ 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().
* *
* This method must be called in the event loop thread. * This method must be called in the event loop thread.
*/ */
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();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment