mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-12-24 11:45:51 +01:00
28 lines
769 B
C++
28 lines
769 B
C++
|
//
|
||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
|
||
|
//
|
||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||
|
//
|
||
|
#include "telegram-bot-api/Watchdog.h"
|
||
|
|
||
|
#include "td/utils/Time.h"
|
||
|
|
||
|
namespace telegram_bot_api {
|
||
|
|
||
|
void Watchdog::kick() {
|
||
|
auto now = td::Time::now();
|
||
|
if (now >= last_kick_time_ + timeout_ && last_kick_time_ > 0) {
|
||
|
LOG(ERROR) << "Watchdog timeout expired after " << now - last_kick_time_ << " seconds";
|
||
|
td::thread::send_real_time_signal(main_thread_id_, 2);
|
||
|
}
|
||
|
last_kick_time_ = now;
|
||
|
set_timeout_in(timeout_);
|
||
|
}
|
||
|
|
||
|
void Watchdog::timeout_expired() {
|
||
|
kick();
|
||
|
}
|
||
|
|
||
|
} // namespace telegram_bot_api
|