PRO

Effect Fair Priority Scheduler

A binary-heap priority queue with FIFO ties and aging so nothing starves. A sorted-array priority queue breaks ties unstably and lets a job's position jump as peers arrive; a binary heap with a monotonic sequence tiebreaker gives a stable total order, highest priority first and first-in-first-out among equals. Strict priority starves the low tier under a steady stream of urgent work, so a job's effective priority rises with the time it has waited, and even the lowest tier eventually outranks fresh arrivals, bounding the worst-case wait. Push and pop are O(log n) heap sifts in a single Ref. The demo starves a backup job under strict priority, then runs it under aging. Pinned to effect 4.0.0-beta.98.

Install
npx shadcn@latest add https://ui.aryank.space/r/effect-fair-priority-scheduler.json

Installs from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.

Visualization
fairness
urgent stream (p9)
Task
backup (p1)
Task
always pop max priority // backup never runs

A steady stream of priority-9 work keeps arriving, so the priority-1 backup job never reaches the front of the heap. Ten rounds pass and it has not run once: starvation.

Files

Dependencies