λ61
Loading...
Searching...
No Matches
AsyncTimer.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 Tetex7
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18//
19// Created by tete on 8/24/25.
20//
21
22#ifndef L61_ASYNCTIMER_HPP
23#define L61_ASYNCTIMER_HPP
25#include <atomic>
26#include <future>
27
29{
31 {
32 private:
33 std::atomic<bool> m_finished{false};
34 std::atomic<bool> m_running{false};
35 std::future<void> m_task;
36 public:
37 explicit AsyncTimer(Mode mode);
38 void start(std::uint32_t duration) override;
39 void reset() override;
40
41 bool isFinished() const override;
42
43 bool isRuning() const;
44
45 ~AsyncTimer() override = default;
46 };
47}
48
49#endif // L61_ASYNCTIMER_HPP
Mode
Definition AbstractTimer.hpp:33
AbstractTimer(Mode mode=Mode::MILLISECONDS)
Definition AbstractTimer.cpp:27
std::atomic< bool > m_finished
Definition AsyncTimer.hpp:33
std::future< void > m_task
Definition AsyncTimer.hpp:35
std::atomic< bool > m_running
Definition AsyncTimer.hpp:34
void start(std::uint32_t duration) override
Definition AsyncTimer.cpp:29
bool isFinished() const override
Definition AsyncTimer.cpp:49
AsyncTimer(Mode mode)
Definition AsyncTimer.cpp:27
bool isRuning() const
Definition AsyncTimer.cpp:54
void reset() override
Definition AsyncTimer.cpp:44
Definition AbstractTimer.hpp:29