Pioneer
LuaTimer.h
Go to the documentation of this file.
1 // Copyright © 2008-2023 Pioneer Developers. See AUTHORS.txt for details
2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3 
4 #ifndef _LUATIMER_H
5 #define _LUATIMER_H
6 
7 #include "DeleteEmitter.h"
8 #include "LuaManager.h"
9 #include "JsonFwd.h"
10 
11 #include <deque>
12 
13 class LuaTimer : public DeleteEmitter {
14 public:
15  LuaTimer();
16  ~LuaTimer();
17 
18  void Init();
19 
20  void Tick();
21  void RemoveAll();
22 
23  // For internal use only
24  void Insert(double at, int callbackId, bool repeats);
25 
26 private:
27  /*
28  * Minimal tracking struct for the next time a callback should be triggered
29  * Avoids the overhead of constant round-trips into Lua
30  */
31  struct CallInfo {
32  double at;
33  int callbackId;
34  bool repeats;
35  };
36 
37  // Queue of tracked 'timeout' entries
38  std::deque<CallInfo> m_timeouts;
39  // Scratch buffer for timeouts that elapsed this update
40  std::vector<CallInfo> m_called;
41 };
42 
43 #endif
Definition: DeleteEmitter.h:16
Definition: LuaTimer.h:13
LuaTimer()
Definition: LuaTimer.cpp:13
void RemoveAll()
Definition: LuaTimer.cpp:35
~LuaTimer()
Definition: LuaTimer.cpp:18
void Insert(double at, int callbackId, bool repeats)
Definition: LuaTimer.cpp:22
void Init()
void Tick()
Definition: LuaTimer.cpp:44