Nui
timer.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <functional>
4 
6 
7 #include <cstdint>
8 
9 namespace Nui
10 {
12  {
13  public:
14  TimerHandle();
15  TimerHandle(int32_t id);
16  TimerHandle(const TimerHandle&) = delete;
17  TimerHandle(TimerHandle&& other);
18  TimerHandle& operator=(const TimerHandle&) = delete;
20 
21  ~TimerHandle();
22 
23  void stop();
24  bool hasActiveTimer() const;
25 
26  private:
27  int32_t id_;
28  };
29 
40  void setInterval(int milliseconds, std::function<void()> toWrap, std::function<void(TimerHandle&&)> callback);
41 
52  void setTimeout(int milliseconds, std::function<void()> toWrap, std::function<void(TimerHandle)> callback);
53 }
Definition: timer.hpp:12
bool hasActiveTimer() const
Definition: timer.cpp:44
~TimerHandle()
Definition: timer.cpp:16
TimerHandle & operator=(const TimerHandle &)=delete
TimerHandle()
Definition: timer.cpp:8
TimerHandle(const TimerHandle &)=delete
void stop()
Definition: timer.cpp:34
Definition: file_dialog.hpp:6
void setTimeout(int milliseconds, std::function< void()> toWrap, std::function< void(TimerHandle)> callback)
Creates a new delayed function that calls "toWrap" after "milliseconds" milliseconds.
Definition: timer.cpp:60
void setInterval(int milliseconds, std::function< void()> toWrap, std::function< void(TimerHandle &&)> callback)
Creates a new timer that calls "toWrap" every "milliseconds" milliseconds.
Definition: timer.cpp:49