bshoshany / thread-pool

BS::thread_pool: a fast, lightweight, and easy-to-use C++17 thread pool library
MIT License
2.21k stars 253 forks source link

[REQ] Is that possible to update the priority ? #153

Closed JD31 closed 1 month ago

JD31 commented 1 month ago

When not started yet, is it possible to change the prioroty of a task ? Thank you.

bshoshany commented 1 month ago

Unfortunately this is not possible, since the tasks are stored in an std::priority_queue, which has the property that once an element has been added to the queue, its priority cannot be changed.

If you tell me what exactly you are trying to do, I could provide ideas for how to implement it. For example, you could include a flag in the task itself that can be used to cancel it, and then if you want to change the priority, you can turn on that flag and resubmit the task.