27 for (
auto& s :
copy) {
28 s.getDevice()->schedulerDeleted();
31 assert(queue.empty());
34void Scheduler::setSyncPoint(EmuTime::param time,
Schedulable& device)
37 assert(time >= scheduleTime);
43 return x.getTime() < y.getTime(); });
45 if (!scheduleInProgress && cpu) {
56 ranges::copy_if(queue, back_inserter(result), EqualSchedulable(device));
63 return queue.remove(EqualSchedulable(device));
66void Scheduler::removeSyncPoints(
Schedulable& device)
69 queue.remove_all(EqualSchedulable(device));
72bool Scheduler::pendingSyncPoint(
const Schedulable& device,
73 EmuTime& result)
const
78 result = it->getTime();
90void Scheduler::scheduleHelper(EmuTime::param limit, EmuTime next)
92 assert(!scheduleInProgress);
93 scheduleInProgress =
true;
95 assert(scheduleTime <= next);
98 const auto& sp = queue.front();
101 queue.remove_front();
103 device->executeUntil(next);
106 if (next > limit) [[likely]]
break;
108 scheduleInProgress =
false;
114template<
typename Archive>
121 ar.serialize(
"time", timeStamp);
125template<
typename Archive>
128 ar.serialize(
"currentTime", scheduleTime);
void setNextSyncPoint(EmuTime::param time)
Every class that wants to get scheduled at some point must inherit from this class.
EmuTime::param getCurrentTime() const
Get the current scheduler time.
void serialize(Archive &ar, unsigned version)
std::vector< SynchronizationPoint > SyncPoints
EmuTime::param getNext() const
TODO.
void serialize(Archive &ar, unsigned version)
void setTime(EmuTime::param time)
Schedulable * getDevice() const
bool isMainThread()
Returns true when called from the main thread.
This file implemented 3 utility functions:
auto copy(InputRange &&range, OutputIter out)
auto find(InputRange &&range, const T &value)
auto copy_if(InputRange &&range, OutputIter out, UnaryPredicate pred)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
auto to_vector(Range &&range) -> std::vector< detail::ToVectorType< T, decltype(std::begin(range))> >
EqualSchedulable(const Schedulable &schedulable_)
bool operator()(const SynchronizationPoint &sp) const
const Schedulable & schedulable
constexpr auto end(const zstring_view &x)