hyprlock/src/core/Timer.hpp

27 lines
757 B
C++
Raw Normal View History

2024-02-20 00:59:35 +00:00
#pragma once
#include <chrono>
#include <functional>
#include "../defines.hpp"
2024-02-20 00:59:35 +00:00
class CTimer {
public:
CTimer(std::chrono::system_clock::duration timeout, std::function<void(ASP<CTimer> self, void* data)> cb_, void* data_, bool force);
2024-02-20 00:59:35 +00:00
void cancel();
bool passed();
bool canForceUpdate();
2024-02-20 00:59:35 +00:00
float leftMs();
bool cancelled();
void call(ASP<CTimer> self);
2024-02-20 00:59:35 +00:00
private:
std::function<void(ASP<CTimer> self, void* data)> cb;
void* data = nullptr;
std::chrono::system_clock::time_point expires;
bool wasCancelled = false;
bool allowForceUpdate = false;
};