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
12
struct
RTSyncPoint
13
{
14
uint64_t
time
;
15
RTSchedulable
*
schedulable
;
16
};
17
18
class
RTScheduler
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
:
42
SchedulerQueue<RTSyncPoint>
queue;
43
};
44
45
}
// namespace openmsx
46
47
#endif
SchedulerQueue.hh
Timer.hh
openmsx::RTSchedulable
Definition
RTSchedulable.hh:11
openmsx::RTScheduler
Definition
RTScheduler.hh:19
openmsx::RTScheduler::execute
void execute()
Execute all expired RTSchedulables.
Definition
RTScheduler.hh:22
openmsx::SchedulerQueue
Definition
SchedulerQueue.hh:20
openmsx::Timer::getTime
uint64_t getTime()
Get current (real) time in us.
Definition
Timer.cc:7
openmsx
This file implemented 3 utility functions:
Definition
Autofire.cc:11
openmsx::RTSyncPoint
Definition
RTScheduler.hh:13
openmsx::RTSyncPoint::time
uint64_t time
Definition
RTScheduler.hh:14
openmsx::RTSyncPoint::schedulable
RTSchedulable * schedulable
Definition
RTScheduler.hh:15
Generated on Mon Oct 7 2024 21:13:40 for openMSX by
1.9.8