event/Loop: use std::chrono

This commit is contained in:
Max Kellermann
2016-12-27 23:06:34 +01:00
parent 3413d1bf23
commit b042095ac2
22 changed files with 92 additions and 78 deletions

View File

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

View File

@@ -25,14 +25,16 @@
#define CLIENT_MAX_COMMAND_LIST_DEFAULT (2048*1024)
#define CLIENT_MAX_OUTPUT_BUFFER_SIZE_DEFAULT (8192*1024)
int client_timeout;
std::chrono::steady_clock::duration client_timeout;
size_t client_max_command_list_size;
size_t client_max_output_buffer_size;
void client_manager_init(void)
{
client_timeout = config_get_positive(ConfigOption::CONN_TIMEOUT,
CLIENT_TIMEOUT_DEFAULT);
unsigned client_timeout_s = config_get_positive(ConfigOption::CONN_TIMEOUT,
CLIENT_TIMEOUT_DEFAULT);
client_timeout = std::chrono::seconds(client_timeout_s);
client_max_command_list_size =
config_get_positive(ConfigOption::MAX_COMMAND_LIST_SIZE,
CLIENT_MAX_COMMAND_LIST_DEFAULT / 1024)

View File

@@ -42,7 +42,7 @@ Client::IdleNotify()
client_puts(*this, "OK\n");
TimeoutMonitor::ScheduleSeconds(client_timeout);
TimeoutMonitor::Schedule(client_timeout);
}
void

View File

@@ -24,12 +24,14 @@
#include "Client.hxx"
#include "command/CommandResult.hxx"
#include <chrono>
static constexpr unsigned CLIENT_MAX_SUBSCRIPTIONS = 16;
static constexpr unsigned CLIENT_MAX_MESSAGES = 64;
extern const class Domain client_domain;
extern int client_timeout;
extern std::chrono::steady_clock::duration client_timeout;
extern size_t client_max_command_list_size;
extern size_t client_max_output_buffer_size;

View File

@@ -53,7 +53,7 @@ Client::Client(EventLoop &_loop, Partition &_partition,
idle_waiting(false), idle_flags(0),
num_subscriptions(0)
{
TimeoutMonitor::ScheduleSeconds(client_timeout);
TimeoutMonitor::Schedule(client_timeout);
}
void

View File

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