Priority Task Queue
Implement a bounded priority queue for a cooperative scheduler where lower numbers mean higher priority, and equal priorities run in insertion order.
Constraints
- Capacity 16, no dynamic allocation.
- Equal priorities must be FIFO - a plain binary heap is not stable.
- push returns false when full.
- pop returns the highest-priority task.
- O(log n) push and pop.
- No std::priority_queue.
1#include <cstddef>2#include <cstdint>3 4struct Task { int priority; void (*run)(); };5 6class TaskQueue {7public:8 bool push(const Task& task);9 bool pop(Task& out);10};