1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:57:44 +00:00

LibCore: Add Core::Timer::create_single_shot()

This is just a convenience function for creating single-shot timers.
This commit is contained in:
Andreas Kling 2020-04-07 22:15:22 +02:00
parent f813041f67
commit a53cf81374
4 changed files with 33 additions and 35 deletions

View file

@ -32,8 +32,16 @@
namespace Core {
class Timer final : public Object {
C_OBJECT(Timer)
C_OBJECT(Timer);
public:
static NonnullRefPtr<Timer> create_single_shot(int interval, Function<void()>&& timeout_handler, Object* parent = nullptr)
{
auto timer = adopt(*new Timer(interval, move(timeout_handler), parent));
timer->set_single_shot(true);
return timer;
}
virtual ~Timer() override;
void start();