openMSX
RTScheduler.hh
Go to the documentation of this file.
1 #ifndef RTSCHEDULER_HH
2 #define RTSCHEDULER_HH
3 
4 #include "SchedulerQueue.hh"
5 #include "Timer.hh"
6 #include "likely.hh"
7 #include <cstdint>
8 
9 namespace openmsx {
10 
11 class RTSchedulable;
12 
14 {
15  uint64_t time;
17 };
18 
20 {
21 public:
23  inline void execute()
24  {
25  auto limit = Timer::getTime();
26  if (!queue.empty() && unlikely(limit >= queue.front().time)) {
27  scheduleHelper(limit); // slow path not inlined
28  }
29  }
30 
31 private:
32  // These are called by RTSchedulable
33  friend class RTSchedulable;
34  void add(uint64_t delta, RTSchedulable& schedulable);
35  bool remove(RTSchedulable& schedulable);
36  bool isPending(const RTSchedulable& schedulable) const;
37 
38 private:
39  void scheduleHelper(uint64_t limit);
40 
42 };
43 
44 } // namespace openmsx
45 
46 #endif
#define unlikely(x)
Definition: likely.hh:15
RTSchedulable * schedulable
Definition: RTScheduler.hh:16
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void execute()
Execute all expired RTSchedulables.
Definition: RTScheduler.hh:23
uint64_t getTime()
Get current (real) time in us.
Definition: Timer.cc:8