2018-07-07 13:08:57 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <functional>
|
2018-07-07 15:50:05 +02:00
|
|
|
|
|
|
|
class QTimer;
|
2018-07-07 13:08:57 +02:00
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
2018-07-07 15:50:05 +02:00
|
|
|
class NetworkWorker;
|
|
|
|
|
2018-07-07 13:08:57 +02:00
|
|
|
class NetworkTimer
|
|
|
|
{
|
2018-07-07 15:50:05 +02:00
|
|
|
QTimer *timer_ = nullptr;
|
2018-07-07 13:08:57 +02:00
|
|
|
|
|
|
|
bool started_{};
|
|
|
|
|
|
|
|
public:
|
|
|
|
int timeoutMS_ = -1;
|
|
|
|
|
|
|
|
NetworkTimer() = default;
|
2018-07-07 15:50:05 +02:00
|
|
|
~NetworkTimer() = default;
|
2018-07-07 13:08:57 +02:00
|
|
|
|
|
|
|
NetworkTimer(const NetworkTimer &other) = delete;
|
|
|
|
NetworkTimer &operator=(const NetworkTimer &other) = delete;
|
|
|
|
|
|
|
|
NetworkTimer(NetworkTimer &&other) = default;
|
|
|
|
NetworkTimer &operator=(NetworkTimer &&other) = default;
|
|
|
|
|
2018-07-07 15:50:05 +02:00
|
|
|
void start();
|
2018-07-07 13:08:57 +02:00
|
|
|
|
2018-07-07 15:50:05 +02:00
|
|
|
void onTimeout(NetworkWorker *worker, std::function<void()> cb) const;
|
2018-07-07 13:08:57 +02:00
|
|
|
|
2018-07-07 15:50:05 +02:00
|
|
|
bool isStarted() const;
|
2018-07-07 13:08:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace chatterino
|