~aleteoryx/muditaos

ref: 9b3f5bf87d97954a08c416736a33d4fab35fdccf muditaos/module-sys/Service/include/Timers/Timer.hpp -rw-r--r-- 982 bytes
9b3f5bf8 — wojtekrzepecki [EGD-1295] Fix deep press with light click 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <chrono>
#include <functional>

namespace sys
{
    class Timer; // Forward declaration
    namespace timer
    {
        using TimerCallback                   = std::function<void(Timer &)>;
        inline constexpr auto InfiniteTimeout = std::chrono::milliseconds::max();
        enum class Type
        {
            Periodic,
            SingleShot
        };
    } // namespace timer

    class Timer
    {
      public:
        virtual ~Timer() noexcept                                   = default;
        virtual void start()                                        = 0;
        virtual void restart(std::chrono::milliseconds newInterval) = 0;
        virtual void stop()                                         = 0;
        virtual bool isActive() const noexcept                      = 0;
    };
} // namespace sys