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 <cstdint>
7 
8 namespace openmsx {
9 
10 class RTSchedulable;
11 
13 {
14  uint64_t time;
16 };
17 
19 {
20 public:
22  inline void execute()
23  {
24  if (!queue.empty()) {
25  auto limit = Timer::getTime();
26  if (limit >= queue.front().time) [[unlikely]] {
27  scheduleHelper(limit); // slow path not inlined
28  }
29  }
30  }
31 
32 private:
33  // These are called by RTSchedulable
34  friend class RTSchedulable;
35  void add(uint64_t delta, RTSchedulable& schedulable);
36  bool remove(RTSchedulable& schedulable);
37  [[nodiscard]] bool isPending(const RTSchedulable& schedulable) const;
38 
39  void scheduleHelper(uint64_t limit);
40 
41 private:
43 };
44 
45 } // namespace openmsx
46 
47 #endif
void execute()
Execute all expired RTSchedulables.
Definition: RTScheduler.hh:22
uint64_t getTime()
Get current (real) time in us.
Definition: Timer.cc:7
This file implemented 3 utility functions:
Definition: Autofire.cc:9
auto remove(ForwardRange &&range, const T &value)
Definition: ranges.hh:232
RTSchedulable * schedulable
Definition: RTScheduler.hh:15