20 std::mutex EventList::mut;
24 std::lock_guard<std::mutex> guard(mut);
25 if (instance ==
nullptr)
33 EventList::EventList()
39 randomGenerator = gen;
44 return randomGenerator;
49 std::lock_guard<std::mutex> guard(mut);
50 std::shared_ptr<Event> e = list.front();
58 std::lock_guard<std::mutex> guard(mut);
61 double time = e->getTime();
68 while(p != list.begin())
70 if ((*--p)->getTime() <=
time)
76 auto it = list.insert(p, e);
85 std::lock_guard<std::mutex> guard(mut);
86 for (
auto it = list.begin(); it != list.end(); it++)
88 if (e.get() == (*it).get())
100 std::lock_guard<std::mutex> guard(mut);
101 return (emptied ?
true : (list.begin() == list.end()));
106 std::lock_guard<std::mutex> guard(mut);
113 std::lock_guard<std::mutex> guard(mut);
114 std::cout <<
"Printing the event list:\n";
115 for (
auto it = list.begin(); it != list.end(); it++)
117 assert((*it) !=
nullptr);
126 std::lock_guard<std::mutex> guard(mut);
127 return (*list.begin());
Utils::RandomGenerator * getRandomGenerator()
get the random generator
void remove(std::shared_ptr< Event > e)
remove an element from the list.
void setRandomGenerator(Utils::RandomGenerator *gen)
set a random generator TODO: shouldn't that be part of the constructor?
std::shared_ptr< Event > getHead()
get the element at the head of the list
std::shared_ptr< Event > pop()
std::shared_ptr< Event > insert(std::shared_ptr< Event > e)
static EventList * getInstance()
Singleton pattern.