Execute Promises with Dynamic Priority Updates and Real-Time Queue Reordering (Part 2)

Enhance the Part 1 priority-based promise executor to support dynamic priority updates — a task's priority can be changed even after it's been enqueued. The queue must re-sort itself after each priority mutation. Also support task cancellation by ID and callback hooks for onStart, onComplete, and onError per task. This is the production-level implementation pattern used in browser rendering queues and request orchestrators.

Examples
Input: []
Output:
Hints

Execute Promises with Dynamic Priority Updates and Real-Time Queue Reordering (Part 2)

Enhance the Part 1 priority-based promise executor to support dynamic priority updates — a task's priority can be changed even after it's been enqueued. The queue must re-sort itself after each priority mutation. Also support task cancellation by ID and callback hooks for onStart, onComplete, and onError per task. This is the production-level implementation pattern used in browser rendering queues and request orchestrators.