Skip to content

Architecture Scheduler

Devrajsinh Gohil edited this page Aug 30, 2026 · 1 revision

O(1) Scheduler & Ready Queue

AgentMesh uses a priority-aware, lock-free ready queue combined with atomic dependency tracking.


PriorityReadyQueue

Tasks are scheduled using a compound ordering key:

  1. Priority (DESC): Higher numerical priority executes first.
  2. Enqueue Timestamp (FIFO): Deterministic tie-breaking for equal priority tasks.
struct QueueComparator {
    bool operator()(const TaskItem& a, const TaskItem& b) const noexcept {
        if (a.priority != b.priority) {
            return a.priority < b.priority; // max-heap
        }
        return a.enqueueTime > b.enqueueTime; // FIFO
    }
};

Dependency Resolution

When a task completes, the scheduler decrements the in-degree of all dependent successor nodes. When in-degree reaches 0, the node is pushed to the ready queue in $O(1)$ time.\n

Clone this wiki locally