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>
105 lines
2.6 KiB
C++
105 lines
2.6 KiB
C++
#include "model_internal.hpp"
|
|
|
|
namespace ps {
|
|
int Model::begin(int actor, int device, unsigned requested, std::uint64_t &token) {
|
|
if (!valid_actor(actor)) {
|
|
return -22;
|
|
}
|
|
int error = device_error(*state, device);
|
|
if (error) {
|
|
return error;
|
|
}
|
|
if (requested & ~15U) {
|
|
return -22;
|
|
}
|
|
auto &entry = state->actors[actor];
|
|
if (entry.view.phase == PREPARED || entry.view.phase == WAITING) {
|
|
return -16;
|
|
}
|
|
Watch fresh;
|
|
fresh.view.device = device;
|
|
fresh.view.requested = requested;
|
|
fresh.view.phase = PREPARED;
|
|
fresh.view.token = state->next_token++;
|
|
entry = fresh;
|
|
subscribe(*state, actor);
|
|
token = entry.view.token;
|
|
return 0;
|
|
}
|
|
|
|
int Model::step(int actor, std::uint64_t token, unsigned &ready) {
|
|
int error = watch_error(*state, actor, token);
|
|
if (error) {
|
|
return error;
|
|
}
|
|
auto &entry = state->actors[actor];
|
|
auto &watch = entry.view;
|
|
if (is_terminal(watch.phase)) {
|
|
ready = watch.ready;
|
|
return terminal_result(watch);
|
|
}
|
|
const auto &device = state->devices[watch.device];
|
|
unsigned available = readiness(device);
|
|
watch.seen = device.generation;
|
|
watch.pending = 0;
|
|
watch.ready = filter_ready(available, watch.requested);
|
|
if (watch.ready != 0) {
|
|
watch.phase = READY;
|
|
unsubscribe(*state, actor);
|
|
ready = watch.ready;
|
|
return 1;
|
|
}
|
|
watch.phase = WAITING;
|
|
ready = 0;
|
|
return 0;
|
|
}
|
|
|
|
int Model::cancel(int actor, std::uint64_t token) {
|
|
int error = watch_error(*state, actor, token);
|
|
if (error) {
|
|
return error;
|
|
}
|
|
auto &watch = state->actors[actor].view;
|
|
if (watch.phase == CANCELLED) {
|
|
return 0;
|
|
}
|
|
if (is_terminal(watch.phase)) {
|
|
return -114;
|
|
}
|
|
return finish_watch(*state, actor, CANCELLED);
|
|
}
|
|
|
|
int Model::interrupt(int actor, std::uint64_t token) {
|
|
int error = watch_error(*state, actor, token);
|
|
if (error) {
|
|
return error;
|
|
}
|
|
auto &watch = state->actors[actor].view;
|
|
if (watch.phase == INTERRUPTED) {
|
|
return 0;
|
|
}
|
|
if (is_terminal(watch.phase)) {
|
|
return -114;
|
|
}
|
|
return finish_watch(*state, actor, INTERRUPTED);
|
|
}
|
|
|
|
int Model::release(int actor, std::uint64_t token) {
|
|
int error = watch_error(*state, actor, token);
|
|
if (error) {
|
|
return error;
|
|
}
|
|
unsubscribe(*state, actor);
|
|
state->actors[actor] = Watch{};
|
|
return 0;
|
|
}
|
|
|
|
int Model::watch(int actor, WatchView &out) const {
|
|
if (!valid_actor(actor)) {
|
|
return -22;
|
|
}
|
|
out = state->actors[actor].view;
|
|
return 0;
|
|
}
|
|
}
|