openMSX
Schedulable.cc
Go to the documentation of this file.
1#include "Schedulable.hh"
2#include "Scheduler.hh"
3#include <iostream>
4
5namespace openmsx {
6
8 : scheduler(scheduler_)
9{
10}
11
16
18{
19 std::cerr << "Internal error: Schedulable \"" << typeid(*this).name()
20 << "\" failed to unregister.\n";
21}
22
23void Schedulable::setSyncPoint(EmuTime::param timestamp)
24{
25 scheduler.setSyncPoint(timestamp, *this);
26}
27
29{
30 return scheduler.removeSyncPoint(*this);
31}
32
34{
35 scheduler.removeSyncPoints(*this);
36}
37
39{
40 auto dummy = EmuTime::dummy();
41 return scheduler.pendingSyncPoint(*this, dummy);
42}
43
44bool Schedulable::pendingSyncPoint(EmuTime& result) const
45{
46 return scheduler.pendingSyncPoint(*this, result);
47}
48
49EmuTime::param Schedulable::getCurrentTime() const
50{
51 return scheduler.getCurrentTime();
52}
53
54template<typename Archive>
55void Schedulable::serialize(Archive& ar, unsigned /*version*/)
56{
57 Scheduler::SyncPoints syncPoints;
58 if constexpr (!Archive::IS_LOADER) {
59 syncPoints = scheduler.getSyncPoints(*this);
60 }
61 ar.serialize("syncPoints", syncPoints);
62 if constexpr (Archive::IS_LOADER) {
64 for (const auto& s : syncPoints) {
65 setSyncPoint(s.getTime());
66 }
67 }
68}
70
71} // namespace openmsx
Every class that wants to get scheduled at some point must inherit from this class.
void setSyncPoint(EmuTime::param timestamp)
void serialize(Archive &ar, unsigned version)
Schedulable(const Schedulable &)=delete
virtual void schedulerDeleted()
Just before the the Scheduler is deleted, it calls this method of all the Schedulables that are still...
bool pendingSyncPoint() const
EmuTime::param getCurrentTime() const
Convenience method: This is the same as getScheduler().getCurrentTime().
EmuTime::param getCurrentTime() const
Get the current scheduler time.
Definition Scheduler.cc:82
std::vector< SynchronizationPoint > SyncPoints
Definition Scheduler.hh:35
This file implemented 3 utility functions:
Definition Autofire.cc:11
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)