ClickHouse/src/IO/TimeoutSetter.h

31 lines
803 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_,
2021-04-29 16:11:20 +00:00
Poco::Timespan send_timeout_,
Poco::Timespan receive_timeout_,
2018-09-28 14:53:20 +00:00
bool limit_max_timeout = false);
2021-04-29 16:11:20 +00:00
TimeoutSetter(Poco::Net::StreamSocket & socket_, 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;
};
}