ClickHouse/dbms/src/Client/TimeoutSetter.h

31 lines
827 B
C++
Raw Normal View History

#pragma once
#include <Poco/Net/StreamSocket.h>
2018-09-28 14:53:20 +00:00
#include <Poco/Timespan.h>
namespace DB
{
2018-09-28 14:53:20 +00:00
/// Temporarily overrides socket send/receive timeouts and reset them back into destructor
2018-04-04 19:44:28 +00:00
/// If "limit_max_timeout" is true, timeouts could be only decreased (maxed by previous value).
struct TimeoutSetter
{
2018-09-28 14:53:20 +00:00
TimeoutSetter(Poco::Net::StreamSocket & socket_,
const Poco::Timespan & send_timeout_,
const Poco::Timespan & receive_timeout_,
bool limit_max_timeout = false);
2018-09-28 14:53:20 +00:00
TimeoutSetter(Poco::Net::StreamSocket & socket_, const Poco::Timespan & timeout_, bool limit_max_timeout = false);
2018-09-28 14:53:20 +00:00
~TimeoutSetter();
Poco::Net::StreamSocket & socket;
Poco::Timespan send_timeout;
2018-09-28 14:53:20 +00:00
Poco::Timespan receive_timeout;
Poco::Timespan old_send_timeout;
Poco::Timespan old_receive_timeout;
};
}