Use case: I want to implement a very efficient send queue for a Linux program sending many rate-limited streams of large numbers of UDP packets per second in a network test program. Currently, I use a
priority_queue< pair<timespec, int>, std::vector<pair<timespec, int>>, std::greater<pair<timespec, int>> > The program functions correctly and is fast. But I would like to be able to pop front of queue and add a new element in one operation, i.e. only one re-heapify per pop/emplace pair. Otherwise, the pop will re-heapify, and then the emplace will directly re-heapify again.
Can this be done with std::make_heap, std::push_heap and std::pop_heap? Or do I have to roll my own? My current program does pop followed by emplace on the std::priority_queue, which costs '2*O(log(N))'.
FWIW, the current program is here: https://github.com/alapaa/timestamping/tree/send_queue
The actual sender with queue is this src file: https://github.com/alapaa/timestamping/blob/send_queue/manysock/sender.cpp