amos 9d633e9e67 Batch 15 (20261023-C-hwe-scale-15): 320 HWE-derived repair tasks
One user-space repair task per eligible HWE debug-diag / compile-deploy base
ID: 320 admitted (C 218, C++ 97, build scripts 5), 1 skipped by the content
filter. Each ships a public spec with a check-to-basis table, at least two
defects with single-fix fixtures, a symptom-masking fixture and an alternative
correct implementation. Claude re-checked all 320: structure, the HWE quality
items and trace6 Docker calibration receipts against current digests
(320/320 USABLE). Difficulty is unmeasured. Known follow-up: 212 tasks use 120
ad-hoc family names; the next batch maps them to the canonical list.
The batch's 1,256-line progress log stays in its factory report and the
36-local branch batch15-hwe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:55:56 +08:00

70 lines
1.8 KiB
C

#include "dispatch.h"
void queue_init(Queue *queue)
{
queue->head = 0;
queue->count = 0;
}
int queue_push(Queue *queue, Message message)
{
if (queue->count >= QUEUE_CAPACITY) return -2;
queue->slots[queue->count++] = message;
return 0;
}
const Message *queue_front(const Queue *queue)
{
return queue->count ? &queue->slots[0] : NULL;
}
const Message *queue_at(const Queue *queue, unsigned ordinal)
{
return ordinal < queue->count ? &queue->slots[ordinal] : NULL;
}
int queue_pop(Queue *queue)
{
unsigned i;
if (!queue->count) return -2;
--queue->count;
for (i=0; i<queue->count; ++i) queue->slots[i]=queue->slots[i+1];
return 0;
}
unsigned queue_age(Queue *queue)
{
unsigned i=0, removed=0;
while (i<queue->count) {
if (--queue->slots[i].lease == 0) {
unsigned j;
--queue->count;
for (j=i; j<queue->count; ++j) queue->slots[j]=queue->slots[j+1];
++removed;
} else ++i;
}
return removed;
}
unsigned queue_clear(Queue *queue)
{
unsigned old=queue->count;
queue->count=0;
return old;
}
unsigned queue_remove_id(Queue *queue, int id)
{
unsigned i=0, removed=0;
while (i<queue->count) {
if (queue->slots[i].id == id) {
unsigned j;
--queue->count;
for (j=i; j<queue->count; ++j) queue->slots[j]=queue->slots[j+1];
++removed;
} else ++i;
}
return removed;
}
int queue_transfer(Queue *source, Queue *target, unsigned count)
{
unsigned i;
if (source==target || count>source->count) return -4;
if (target->count+count>QUEUE_CAPACITY) return -2;
for (i=0; i<count; ++i) queue_push(target,source->slots[i]);
for (i=0; i<count; ++i) queue_pop(source);
return 0;
}