Client: migrate from TimeoutMonitor to TimerEvent

This commit is contained in:
Max Kellermann 2017-08-29 16:22:01 +02:00
parent 30a5dd267b
commit fd520eeed2
5 changed files with 12 additions and 10 deletions

View File

@ -25,7 +25,7 @@
#include "command/CommandListBuilder.hxx"
#include "tag/Mask.hxx"
#include "event/FullyBufferedSocket.hxx"
#include "event/TimeoutMonitor.hxx"
#include "event/TimerEvent.hxx"
#include "Compiler.h"
#include <boost/intrusive/link_mode.hpp>
@ -49,8 +49,10 @@ class Database;
class Storage;
class Client final
: FullyBufferedSocket, TimeoutMonitor,
: FullyBufferedSocket,
public boost::intrusive::list_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>> {
TimerEvent timeout_event;
Partition *partition;
public:
@ -228,8 +230,8 @@ private:
void OnSocketError(std::exception_ptr ep) override;
void OnSocketClosed() override;
/* virtual methods from class TimeoutMonitor */
void OnTimeout() override;
/* callback for TimerEvent */
void OnTimeout();
};
void

View File

@ -28,7 +28,7 @@ Client::SetExpired()
return;
FullyBufferedSocket::Close();
TimeoutMonitor::Schedule(std::chrono::steady_clock::duration::zero());
timeout_event.Schedule(std::chrono::steady_clock::duration::zero());
}
void

View File

@ -42,7 +42,7 @@ Client::IdleNotify()
Write("OK\n");
TimeoutMonitor::Schedule(client_timeout);
timeout_event.Schedule(client_timeout);
}
void
@ -69,7 +69,7 @@ Client::IdleWait(unsigned flags)
return true;
} else {
/* disable timeouts while in "idle" */
TimeoutMonitor::Cancel();
timeout_event.Cancel();
return false;
}
}

View File

@ -45,13 +45,13 @@ Client::Client(EventLoop &_loop, Partition &_partition,
UniqueSocketDescriptor &&_fd, int _uid, int _num)
:FullyBufferedSocket(_fd.Release(), _loop,
16384, client_max_output_buffer_size),
TimeoutMonitor(_loop),
timeout_event(_loop, BIND_THIS_METHOD(OnTimeout)),
partition(&_partition),
permission(getDefaultPermissions()),
uid(_uid),
num(_num)
{
TimeoutMonitor::Schedule(client_timeout);
timeout_event.Schedule(client_timeout);
}
void

View File

@ -34,7 +34,7 @@ Client::OnSocketInput(void *data, size_t length)
if (newline == nullptr)
return InputResult::MORE;
TimeoutMonitor::Schedule(client_timeout);
timeout_event.Schedule(client_timeout);
BufferedSocket::ConsumeInput(newline + 1 - p);