mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
Addition to prev. revision [#METR-23237].
This commit is contained in:
parent
39f2527012
commit
181c2302fc
@ -34,23 +34,16 @@ ActiveMetrics::~ActiveMetrics()
|
||||
|
||||
void ActiveMetrics::run()
|
||||
{
|
||||
using namespace std::literals;
|
||||
|
||||
setThreadName("ActiveMetrics");
|
||||
|
||||
std::this_thread::sleep_for(30s); /// To be distant with moment of transmission of metrics. It is not strictly necessary.
|
||||
|
||||
const auto get_next_minute = []
|
||||
{
|
||||
return std::chrono::time_point_cast<std::chrono::minutes, std::chrono::system_clock>(
|
||||
std::chrono::system_clock::now() + std::chrono::minutes(1));
|
||||
};
|
||||
|
||||
std::unique_lock<std::mutex> lock{mutex};
|
||||
|
||||
/// To be distant with moment of transmission of metrics. It is not strictly necessary.
|
||||
cond.wait_until(lock, std::chrono::system_clock::now() + std::chrono::seconds(30), [this] { return quit; });
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (cond.wait_until(lock, get_next_minute(), [this] { return quit; }))
|
||||
if (cond.wait_until(lock, std::chrono::system_clock::now() + std::chrono::seconds(60), [this] { return quit; }))
|
||||
break;
|
||||
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user