Skip to content

Commit

Permalink
Correctly handle duplicate peq entries
Browse files Browse the repository at this point in the history
  • Loading branch information
janweinstock committed Dec 17, 2023
1 parent 224aa19 commit 8a2ee56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/vcml/core/peq.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ inline void peq<T>::notify(const T& payload, double t, sc_time_unit tu) {
template <typename T>
inline void peq<T>::notify(const T& payload, const sc_time& delta) {
sc_time t = sc_time_stamp() + delta;
auto range = m_schedule.equal_range(t);
for (auto it = range.first; it != range.second; it++)
if (it->second == payload)
return;

m_schedule.emplace(t, payload);
m_event.notify(m_schedule.begin()->first - sc_time_stamp());
}
Expand Down
1 change: 1 addition & 0 deletions test/core/peq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class peq_test : public test_base
queue.notify(2, 2.0, SC_SEC);
queue.notify(1, 1.0, SC_SEC);
queue.notify(3, 3.0, SC_SEC);
queue.notify(3, 3.0, SC_SEC);

queue.wait(val);
EXPECT_EQ(val, 1);
Expand Down

0 comments on commit 8a2ee56

Please sign in to comment.