lib/curl/Global: migrate from TimeoutMonitor to TimerEvent
This commit is contained in:
parent
2e471daef1
commit
c24b8460e0
|
@ -96,7 +96,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
CurlGlobal::CurlGlobal(EventLoop &_loop)
|
CurlGlobal::CurlGlobal(EventLoop &_loop)
|
||||||
:TimeoutMonitor(_loop), DeferredMonitor(_loop)
|
:DeferredMonitor(_loop),
|
||||||
|
timeout_event(_loop, BIND_THIS_METHOD(OnTimeout))
|
||||||
{
|
{
|
||||||
multi.SetOption(CURLMOPT_SOCKETFUNCTION, CurlSocket::SocketFunction);
|
multi.SetOption(CURLMOPT_SOCKETFUNCTION, CurlSocket::SocketFunction);
|
||||||
multi.SetOption(CURLMOPT_SOCKETDATA, this);
|
multi.SetOption(CURLMOPT_SOCKETDATA, this);
|
||||||
|
@ -222,7 +223,7 @@ inline void
|
||||||
CurlGlobal::UpdateTimeout(long timeout_ms)
|
CurlGlobal::UpdateTimeout(long timeout_ms)
|
||||||
{
|
{
|
||||||
if (timeout_ms < 0) {
|
if (timeout_ms < 0) {
|
||||||
TimeoutMonitor::Cancel();
|
timeout_event.Cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +234,7 @@ CurlGlobal::UpdateTimeout(long timeout_ms)
|
||||||
of 10ms. */
|
of 10ms. */
|
||||||
timeout_ms = 10;
|
timeout_ms = 10;
|
||||||
|
|
||||||
TimeoutMonitor::Schedule(std::chrono::milliseconds(timeout_ms));
|
timeout_event.Schedule(std::chrono::milliseconds(timeout_ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#define CURL_GLOBAL_HXX
|
#define CURL_GLOBAL_HXX
|
||||||
|
|
||||||
#include "Multi.hxx"
|
#include "Multi.hxx"
|
||||||
#include "event/TimeoutMonitor.hxx"
|
#include "event/TimerEvent.hxx"
|
||||||
#include "event/DeferredMonitor.hxx"
|
#include "event/DeferredMonitor.hxx"
|
||||||
|
|
||||||
class CurlSocket;
|
class CurlSocket;
|
||||||
|
@ -40,13 +40,15 @@ class CurlRequest;
|
||||||
/**
|
/**
|
||||||
* Manager for the global CURLM object.
|
* Manager for the global CURLM object.
|
||||||
*/
|
*/
|
||||||
class CurlGlobal final : TimeoutMonitor, DeferredMonitor {
|
class CurlGlobal final : DeferredMonitor {
|
||||||
CurlMulti multi;
|
CurlMulti multi;
|
||||||
|
|
||||||
|
TimerEvent timeout_event;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CurlGlobal(EventLoop &_loop);
|
explicit CurlGlobal(EventLoop &_loop);
|
||||||
|
|
||||||
using TimeoutMonitor::GetEventLoop;
|
using DeferredMonitor::GetEventLoop;
|
||||||
|
|
||||||
void Add(CURL *easy, CurlRequest &request);
|
void Add(CURL *easy, CurlRequest &request);
|
||||||
void Remove(CURL *easy);
|
void Remove(CURL *easy);
|
||||||
|
@ -82,8 +84,8 @@ private:
|
||||||
void UpdateTimeout(long timeout_ms);
|
void UpdateTimeout(long timeout_ms);
|
||||||
static int TimerFunction(CURLM *global, long timeout_ms, void *userp);
|
static int TimerFunction(CURLM *global, long timeout_ms, void *userp);
|
||||||
|
|
||||||
/* virtual methods from class TimeoutMonitor */
|
/* callback for #timeout_event */
|
||||||
void OnTimeout() override;
|
void OnTimeout();
|
||||||
|
|
||||||
/* virtual methods from class DeferredMonitor */
|
/* virtual methods from class DeferredMonitor */
|
||||||
void RunDeferred() override;
|
void RunDeferred() override;
|
||||||
|
|
Loading…
Reference in New Issue