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  [[nodiscard]] bool isPending(const RTSchedulable& schedulable) const;
37 
38  void scheduleHelper(uint64_t limit);
39 
40 private:
42 };
43 
44 } // namespace openmsx
45 
46 #endif
unlikely
#define unlikely(x)
Definition: likely.hh:15
openmsx::RTSchedulable
Definition: RTSchedulable.hh:11
Timer.hh
openmsx::RTSyncPoint::schedulable
RTSchedulable * schedulable
Definition: RTScheduler.hh:16
openmsx::RTSyncPoint
Definition: RTScheduler.hh:14
openmsx::Timer::getTime
uint64_t getTime()
Get current (real) time in us.
Definition: Timer.cc:7
openmsx::RTScheduler
Definition: RTScheduler.hh:20
openmsx::RTScheduler::execute
void execute()
Execute all expired RTSchedulables.
Definition: RTScheduler.hh:23
SchedulerQueue.hh
likely.hh
openmsx::SchedulerQueue
Definition: SchedulerQueue.hh:20
ranges::remove
auto remove(ForwardRange &&range, const T &value)
Definition: ranges.hh:167
openmsx::RTSyncPoint::time
uint64_t time
Definition: RTScheduler.hh:15
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5