[ion] Events::Journal has isEmpty

This commit is contained in:
Romain Goyet
2020-09-10 16:23:33 -04:00
committed by Léa Saviot
parent 22b6990e63
commit f4905c59a2
3 changed files with 9 additions and 3 deletions

View File

@@ -57,6 +57,7 @@ class Journal {
public:
virtual void pushEvent(Event e) = 0;
virtual Event popEvent() = 0;
virtual bool isEmpty() = 0;
};
void replayFrom(Journal * l);

View File

@@ -125,11 +125,10 @@ void logTo(Journal * l) { sDestinationJournal = l; }
Event getEvent(int * timeout) {
if (sSourceJournal != nullptr) {
Event e = sSourceJournal->popEvent();
if (e == None) {
if (sSourceJournal->isEmpty()) {
sSourceJournal = nullptr;
} else {
return e;
return sSourceJournal->popEvent();
}
}
Event e = innerGetEvent(timeout);

View File

@@ -12,10 +12,16 @@ public:
m_eventStorage.push(e);
}
virtual Event popEvent() override {
if (isEmpty()) {
return Ion::Events::None;
}
Event e = m_eventStorage.front();
m_eventStorage.pop();
return e;
}
virtual bool isEmpty() override {
return m_eventStorage.empty();
}
private:
std::queue<Event> m_eventStorage;
};