Some reason: I am creating a thread manager C++that allows the user to create an object AsyncJoband prioritize execution. I have a JobManagersingleton class that manages the priority queue for these AsyncJobsand assigns them to the stream when it is available.
Problem. Users should be able to change priority AFTER. For example, based on some runtime events, a file may need to be downloaded more urgently than others. The problem I am facing is that priority queues only reorder items in the internal heap when calling push()or pop(). As far as I know, there is no open interface that allows you to request reordering based on changing priorities.
What I would like to do is something like this:
- Create
hashmapin my class JobManagerthat contains pointers to objects in the priority queue - A user can access a given task by his key and update priority through a hash map
- It then
JobManagersignals priority queues that have changed priorities. - Priority queue reorders itself
What would be the best way to do this? Should I expect to create my own priority queue class? Or perhaps extends from std::priority_queue?
Thank!
source
share