event/MultiSocketMonitor: migrate from TimeoutMonitor to TimerEvent
This commit is contained in:
parent
11f36c0bd6
commit
7ae57a3531
@ -28,7 +28,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
MultiSocketMonitor::MultiSocketMonitor(EventLoop &_loop)
|
MultiSocketMonitor::MultiSocketMonitor(EventLoop &_loop)
|
||||||
:IdleMonitor(_loop), TimeoutMonitor(_loop) {
|
:IdleMonitor(_loop),
|
||||||
|
timeout_event(_loop, BIND_THIS_METHOD(OnTimeout)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -38,7 +39,7 @@ MultiSocketMonitor::Reset()
|
|||||||
|
|
||||||
fds.clear();
|
fds.clear();
|
||||||
IdleMonitor::Cancel();
|
IdleMonitor::Cancel();
|
||||||
TimeoutMonitor::Cancel();
|
timeout_event.Cancel();
|
||||||
ready = refresh = false;
|
ready = refresh = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,9 +82,9 @@ MultiSocketMonitor::Prepare()
|
|||||||
{
|
{
|
||||||
const auto timeout = PrepareSockets();
|
const auto timeout = PrepareSockets();
|
||||||
if (timeout >= timeout.zero())
|
if (timeout >= timeout.zero())
|
||||||
TimeoutMonitor::Schedule(timeout);
|
timeout_event.Schedule(timeout);
|
||||||
else
|
else
|
||||||
TimeoutMonitor::Cancel();
|
timeout_event.Cancel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
#include "IdleMonitor.hxx"
|
#include "IdleMonitor.hxx"
|
||||||
#include "TimeoutMonitor.hxx"
|
#include "TimerEvent.hxx"
|
||||||
#include "SocketMonitor.hxx"
|
#include "SocketMonitor.hxx"
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ class EventLoop;
|
|||||||
* In PrepareSockets(), use UpdateSocketList() and AddSocket().
|
* In PrepareSockets(), use UpdateSocketList() and AddSocket().
|
||||||
* DispatchSockets() will be called if at least one socket is ready.
|
* DispatchSockets() will be called if at least one socket is ready.
|
||||||
*/
|
*/
|
||||||
class MultiSocketMonitor : IdleMonitor, TimeoutMonitor
|
class MultiSocketMonitor : IdleMonitor
|
||||||
{
|
{
|
||||||
class SingleFD final : public SocketMonitor {
|
class SingleFD final : public SocketMonitor {
|
||||||
MultiSocketMonitor &multi;
|
MultiSocketMonitor &multi;
|
||||||
@ -97,6 +97,8 @@ class MultiSocketMonitor : IdleMonitor, TimeoutMonitor
|
|||||||
|
|
||||||
friend class SingleFD;
|
friend class SingleFD;
|
||||||
|
|
||||||
|
TimerEvent timeout_event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DispatchSockets() should be called.
|
* DispatchSockets() should be called.
|
||||||
*/
|
*/
|
||||||
@ -224,7 +226,7 @@ private:
|
|||||||
|
|
||||||
void Prepare();
|
void Prepare();
|
||||||
|
|
||||||
virtual void OnTimeout() final {
|
void OnTimeout() {
|
||||||
SetReady();
|
SetReady();
|
||||||
IdleMonitor::Schedule();
|
IdleMonitor::Schedule();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user