Workflow and Source Panels
Work Queue Panel
Model queued PHP work as deterministic data and replay each queue step.
work queue
A queue can be replayed without timers when each work item is represented by fixed data.
Work Queue Panel
work_queue_panel.php
Replay: real traced execution (multi-file project)
<?php
$extra = "audit";
$queue = [
["name" => "read", "cost" => 1],
["name" => $extra, "cost" => 2],
["name" => "write", "cost" => 3]
];
$log = "";
$total = 0;
while (count($queue) > 0) {
$event = array_shift($queue);
$total = $total + $event["cost"];
$label = "run:" . $event["name"];
$log = $log === "" ? $label : $log . "," . $label;
}
echo "extra=" . $extra . "\n";
echo "log=" . $log . "\n";
echo "total=" . $total . "\n";
<?php
$extra = "read";
$queue = [
["name" => "read", "cost" => 1],
["name" => $extra, "cost" => 2],
["name" => "write", "cost" => 3]
];
$log = "";
$total = 0;
while (count($queue) > 0) {
$event = array_shift($queue);
$total = $total + $event["cost"];
$label = "run:" . $event["name"];
$log = $log === "" ? $label : $log . "," . $label;
}
echo "extra=" . $extra . "\n";
echo "log=" . $log . "\n";
echo "total=" . $total . "\n";
<?php
$extra = "render";
$queue = [
["name" => "read", "cost" => 1],
["name" => $extra, "cost" => 2],
["name" => "write", "cost" => 3]
];
$log = "";
$total = 0;
while (count($queue) > 0) {
$event = array_shift($queue);
$total = $total + $event["cost"];
$label = "run:" . $event["name"];
$log = $log === "" ? $label : $log . "," . $label;
}
echo "extra=" . $extra . "\n";
echo "log=" . $log . "\n";
echo "total=" . $total . "\n";
$extra ← audit, $queue ← Array, $log ← (empty), $total ← 0
1<?php2$extra→ audit = "audit"; //@extra="read", "render"3$queue→ Array = [4 ["name" => "read", "cost" => 1],5 ["name" => $extraaudit, "cost" => 2],6 ["name" => "write", "cost" => 3]7];89$log→ (empty) = "";10$total→ 0 = 0;$event ← Array, $total ← 1, $label ← run:read, $log ← run:read
pass 1 of 312while (count($queueArray) > 0) {13 $event→ Array = array_shift($queueArray);14 $total→ 1 = $total + $event["cost"]1;15 $label→ run:read = "run:" . $event["name"]read;16 $log→ run:read = $log === "" ? $label : $log . "," . $labelrun:read;17}All 3 passes — pass 1 is the card above pass $event["cost"]$event["name"]$event$total$label$log1 1 read Array 0 → 1 run:read (empty) → run:read 2 2 audit Array 1 → 3 run:audit run:read → run:read,run:audit 3 3 write Array 3 → 6 run:write run:read,run:audit → run:read,run:audit,run:write echo "extra=" . $extra . " ";
19echo "extra=" . $extraaudit . "\n";20echo "log=" . $logrun:read,run:audit,run:write . "\n";21echo "total=" . $total6 . "\n";outputextra=audit log=run:read,run:audit,run:write total=6
$extra ← read, $queue ← Array, $log ← (empty), $total ← 0
1<?php2$extra→ read = "read";3$queue→ Array = [4 ["name" => "read", "cost" => 1],5 ["name" => $extraread, "cost" => 2],6 ["name" => "write", "cost" => 3]7];89$log→ (empty) = "";10$total→ 0 = 0;$event ← Array, $total ← 1, $label ← run:read, $log ← run:read
pass 1 of 312while (count($queueArray) > 0) {13 $event→ Array = array_shift($queueArray);14 $total→ 1 = $total + $event["cost"]1;15 $label→ run:read = "run:" . $event["name"]read;16 $log→ run:read = $log === "" ? $label : $log . "," . $labelrun:read;17}All 3 passes — pass 1 is the card above pass $event["cost"]$event["name"]$event$total$label$log1 1 read Array 0 → 1 run:read (empty) → run:read 2 2 read Array 1 → 3 run:read run:read → run:read,run:read 3 3 write Array 3 → 6 run:write run:read,run:read → run:read,run:read,run:write echo "extra=" . $extra . " ";
19echo "extra=" . $extraread . "\n";20echo "log=" . $logrun:read,run:read,run:write . "\n";21echo "total=" . $total6 . "\n";outputextra=read log=run:read,run:read,run:write total=6
$extra ← render, $queue ← Array, $log ← (empty), $total ← 0
1<?php2$extra→ render = "render";3$queue→ Array = [4 ["name" => "read", "cost" => 1],5 ["name" => $extrarender, "cost" => 2],6 ["name" => "write", "cost" => 3]7];89$log→ (empty) = "";10$total→ 0 = 0;$event ← Array, $total ← 1, $label ← run:read, $log ← run:read
pass 1 of 312while (count($queueArray) > 0) {13 $event→ Array = array_shift($queueArray);14 $total→ 1 = $total + $event["cost"]1;15 $label→ run:read = "run:" . $event["name"]read;16 $log→ run:read = $log === "" ? $label : $log . "," . $labelrun:read;17}All 3 passes — pass 1 is the card above pass $event["cost"]$event["name"]$event$total$label$log1 1 read Array 0 → 1 run:read (empty) → run:read 2 2 render Array 1 → 3 run:render run:read → run:read,run:render 3 3 write Array 3 → 6 run:write run:read,run:render → run:read,run:render,run:write echo "extra=" . $extra . " ";
19echo "extra=" . $extrarender . "\n";20echo "log=" . $logrun:read,run:render,run:write . "\n";21echo "total=" . $total6 . "\n";outputextra=render log=run:read,run:render,run:write total=6