amos 2f32624d3b Batch 18 (20261026-C-hwe-codegen-18): add 100 calibrated HWE code-gen tasks; pause production for rollout
100 tasks from the HWE arm-linux code-gen pool (outside the lk/man/pth
range given to batch 22), each with at least one independent
contract-edge defect and plain public docs. Claude reviewed 100/100
USABLE against current digests; no ID or source overlap with main or
batch 22. Difficulty is unmeasured.

progress.md records the wrap-up: all Codex sessions and Qwen schedulers
stopped for the user's rollout, Qwen results so far (57 HARD of 373),
and what is left on each batch branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 17:52:13 +08:00

129 lines
3.4 KiB
C++

#include "interest.hpp"
namespace interest {
void Reactor::observe_descriptor(int fd, View& view) const {
const Descriptor& descriptor = descriptors_[fd];
view.live = descriptor.live ? 1 : 0;
view.generation = descriptor.generation;
view.raw = descriptor.raw;
}
void Reactor::observe_registration(int fd, View& view) const {
const Registration& registration = registrations_[fd];
if (!registration.present) {
return;
}
view.registered = 1;
view.mask = registration.mask;
view.mode = registration.mode;
view.cookie = registration.cookie;
view.armed = registration.armed ? 1 : 0;
view.pending = registration.pending;
view.queued = registration.queued ? 1 : 0;
}
View Reactor::inspect(std::int64_t fd) const {
View result;
if (!fd_valid(fd)) {
result.status = Invalid;
return result;
}
int key = static_cast<int>(fd);
observe_descriptor(key, result);
observe_registration(key, result);
return result;
}
void Reactor::count_descriptor(int fd, Stats& result) const {
if (descriptors_[fd].live) {
result.opened += 1;
}
}
void Reactor::count_registration(int fd, Stats& result) const {
const Registration& registration = registrations_[fd];
if (!registration.present) {
return;
}
result.registered += 1;
if (registration.armed) {
result.armed += 1;
}
if (registration.queued) {
result.queued += 1;
}
int bits = effective(fd);
if (bits & Input) {
result.input_ready += 1;
}
if (bits & Output) {
result.output_ready += 1;
}
if (bits & Error) {
result.error_ready += 1;
}
if (bits & Hangup) {
result.hangup_ready += 1;
}
if (bits != 0) {
result.effective += 1;
}
}
Stats Reactor::stats() const {
Stats result;
for (int fd = 0; fd < DescriptorLimit; ++fd) {
count_descriptor(fd, result);
count_registration(fd, result);
}
result.waits = waits_;
result.emitted = emitted_;
return result;
}
bool Reactor::page_valid(std::int64_t start, std::int64_t limit) {
if (start < 0 || start > DescriptorLimit) {
return false;
}
if (limit < 0 || limit > InterestLimit) {
return false;
}
return true;
}
int Reactor::next_registered(int start) const {
for (int fd = start; fd < DescriptorLimit; ++fd) {
if (registrations_[fd].present) {
return fd;
}
}
return DescriptorLimit;
}
Entry Reactor::make_entry(int fd) const {
Entry entry;
entry.fd = fd;
observe_descriptor(fd, entry.view);
observe_registration(fd, entry.view);
return entry;
}
Page Reactor::list(std::int64_t start, std::int64_t limit) const {
Page result;
if (!page_valid(start, limit)) {
result.status = Invalid;
return result;
}
int cursor = static_cast<int>(start);
if (limit == 0) {
result.next = cursor;
return result;
}
while (cursor < DescriptorLimit) {
int fd = next_registered(cursor);
if (fd == DescriptorLimit) {
result.next = DescriptorLimit;
return result;
}
result.entries.push_back(make_entry(fd));
cursor = fd + 1;
if (result.entries.size() == static_cast<std::size_t>(limit)) {
result.next = next_registered(cursor);
return result;
}
}
result.next = DescriptorLimit;
return result;
}
}