26 for (
auto copy =
to_vector(queue);
auto& s : copy) {
27 s.getDevice()->schedulerDeleted();
29 assert(queue.empty());
32void Scheduler::setSyncPoint(EmuTime::param time,
Schedulable& device)
35 assert(time >= scheduleTime);
40 [](
const SynchronizationPoint& x,
const SynchronizationPoint& y) {
41 return x.getTime() < y.getTime(); });
43 if (!scheduleInProgress && cpu) {
54 ranges::copy_if(queue, back_inserter(result), EqualSchedulable(device));
58bool Scheduler::removeSyncPoint(
const Schedulable& device)
61 return queue.remove(EqualSchedulable(device));
64void Scheduler::removeSyncPoints(
const Schedulable& device)
67 queue.remove_all(EqualSchedulable(device));
70bool Scheduler::pendingSyncPoint(
const Schedulable& device,
71 EmuTime& result)
const
75 it != std::end(queue)) {
76 result = it->getTime();
88void Scheduler::scheduleHelper(EmuTime::param limit, EmuTime next)
90 assert(!scheduleInProgress);
91 scheduleInProgress =
true;
93 assert(scheduleTime <= next);
96 const auto& sp = queue.front();
101 device->executeUntil(next);
104 if (next > limit) [[likely]]
break;
106 scheduleInProgress =
false;
112template<
typename Archive>
119 ar.serialize(
"time", timeStamp);
123template<
typename Archive>
126 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 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