// tiny_ready_bg.h - Ready Aggregator (background/best-effort) #pragma once #include #include #include "tiny_ready.h" #include "box/mailbox_box.h" #include "hakmem_tiny_superslab.h" // Periodic, best-effort aggregator: // - Peeks mailbox (non-destructive) and pushes one candidate into Ready // - Optional: could peek registry in future, but keep it lightweight here static inline void tiny_ready_bg_aggregate_step(int class_idx, int mail_budget) { if (!tiny_ready_enabled()) return; if (mail_budget <= 0) mail_budget = 1; for (int n = 0; n < mail_budget; n++) { uintptr_t ent = mailbox_box_peek_one(class_idx); if (!ent) break; SuperSlab* ss = slab_entry_ss(ent); int slab_idx = slab_entry_idx(ent); if (!(ss && ss->magic == SUPERSLAB_MAGIC)) continue; if (slab_idx < 0 || slab_idx >= ss_slabs_capacity(ss)) continue; tiny_ready_push(class_idx, ss, slab_idx); break; // push only one hint per step by default } }