Bugzilla – Bug 2503
PriorityQueueScheduler
Last modified: 2020-05-12 21:36:05 UTC
I have implemented a scheduler based on priority_queue. According to scheduler benchmark, it is faster than map scheduler, but slower than fixed (see bug 2498) calendar scheduler. Unlike calendar scheduler, it should be safe to make priority queue scheduler default one, because it is just a general-purpose priority queue. Code is available at: https://github.com/avkrotov/ns-3-dev-git/commits/scheduler I had to delete Scheduler::Remove method and replace it with Scheduler::Cancel everywhere, because std::priority_queue does not provide required interfaces. It is a well-known bug, see for example: https://stackoverflow.com/questions/19467485/c-priority-queue-removing-element-not-at-top Anyway, I think replacing Scheduler::Remove with Scheduler::Cancel everywhere is an improvement. Scheduler::Cancel is never slower and Scheduler::Remove is not more safe or something. Providing two interfaces that actually do the same is confusing, in some places code even Cancel immediately after Remove.
Cancel just marks the events as cancelled. Remove actually removes them from the Scheduler, freeing memory. There are cases where one or the other is a better choice, so I'd prefer to leave Remove as an option. +1 to replace with Cancel(), making this a GCI task +1 to implement priority_queue, making this a GCI task
Need to add this to bench-simulator as well, making a GCI task.
My mistake, I see the first commit *does* add it to bench-simulator.
This is three contributions. Complete the set of comparison operators (< == != >) for Event and EventKey Alexander Krotov's PriorityQueueScheduler, from Bug 2503 GCI 2019 patch which implements Remove for the PriorityQueueScheduler (the underlying std::priority_scheduler doesn't support remove() natively.) Upstream merge request: https://gitlab.com/nsnam/ns-3-dev/-/merge_requests/199 Please DO NOT SQUASH these on merge.
Added to ns-3-dev in a series of patches from Peter, starting at commit 4434c65c
Replace Remove with Cancel merged in 1f3735f6f06d7b58d634c51e89af6f3bd9145deb