/* * Copyright (c) 2022, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include namespace Web::Platform { Timer::~Timer() = default; NonnullRefPtr Timer::create() { return EventLoopPlugin::the().create_timer(); } NonnullRefPtr Timer::create_repeating(int interval_ms, Function&& timeout_handler) { auto timer = EventLoopPlugin::the().create_timer(); timer->set_single_shot(false); timer->set_interval(interval_ms); timer->on_timeout = move(timeout_handler); return timer; } NonnullRefPtr Timer::create_single_shot(int interval_ms, Function&& timeout_handler) { auto timer = EventLoopPlugin::the().create_timer(); timer->set_single_shot(true); timer->set_interval(interval_ms); timer->on_timeout = move(timeout_handler); return timer; } }