lib/curl/Global: migrate from TimeoutMonitor to TimerEvent

This commit is contained in:
Max Kellermann 2017-08-29 16:33:20 +02:00
parent 2e471daef1
commit c24b8460e0
2 changed files with 11 additions and 8 deletions

View File

@ -96,7 +96,8 @@ private:
};
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_SOCKETDATA, this);
@ -222,7 +223,7 @@ inline void
CurlGlobal::UpdateTimeout(long timeout_ms)
{
if (timeout_ms < 0) {
TimeoutMonitor::Cancel();
timeout_event.Cancel();
return;
}
@ -233,7 +234,7 @@ CurlGlobal::UpdateTimeout(long timeout_ms)
of 10ms. */
timeout_ms = 10;
TimeoutMonitor::Schedule(std::chrono::milliseconds(timeout_ms));
timeout_event.Schedule(std::chrono::milliseconds(timeout_ms));
}
int

View File

@ -31,7 +31,7 @@
#define CURL_GLOBAL_HXX
#include "Multi.hxx"
#include "event/TimeoutMonitor.hxx"
#include "event/TimerEvent.hxx"
#include "event/DeferredMonitor.hxx"
class CurlSocket;
@ -40,13 +40,15 @@ class CurlRequest;
/**
* Manager for the global CURLM object.
*/
class CurlGlobal final : TimeoutMonitor, DeferredMonitor {
class CurlGlobal final : DeferredMonitor {
CurlMulti multi;
TimerEvent timeout_event;
public:
explicit CurlGlobal(EventLoop &_loop);
using TimeoutMonitor::GetEventLoop;
using DeferredMonitor::GetEventLoop;
void Add(CURL *easy, CurlRequest &request);
void Remove(CURL *easy);
@ -82,8 +84,8 @@ private:
void UpdateTimeout(long timeout_ms);
static int TimerFunction(CURLM *global, long timeout_ms, void *userp);
/* virtual methods from class TimeoutMonitor */
void OnTimeout() override;
/* callback for #timeout_event */
void OnTimeout();
/* virtual methods from class DeferredMonitor */
void RunDeferred() override;