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>
86 lines
2.4 KiB
C++
86 lines
2.4 KiB
C++
#include "storage.hpp"
|
|
namespace instance {
|
|
Resource Ledger::Impl::export_slot(Integer index) const {
|
|
Resource result;
|
|
if (!valid_slot(index)) {
|
|
result.code = Code::RANGE;
|
|
return result;
|
|
}
|
|
const Slot &slot = slots[static_cast<std::size_t>(index)];
|
|
result.active = slot.active;
|
|
result.epoch = slot.serial;
|
|
result.token = slot.token;
|
|
result.owner = slot.owner;
|
|
result.value = slot.value;
|
|
result.waiters.reserve(slot.queue.size());
|
|
for (Integer participant : slot.queue) {
|
|
result.waiters.push_back(participant);
|
|
}
|
|
return result;
|
|
}
|
|
Participant Ledger::Impl::export_actor(Integer participant) const {
|
|
Participant result;
|
|
if (!valid_actor(participant)) {
|
|
result.code = Code::RANGE;
|
|
return result;
|
|
}
|
|
const Actor &actor = actors[static_cast<std::size_t>(participant)];
|
|
result.kind = actor.kind;
|
|
result.slot = actor.slot;
|
|
result.epoch = actor.epoch;
|
|
return result;
|
|
}
|
|
Reply Ledger::read(Handle handle) const {
|
|
Reply result;
|
|
result.code = impl_->resolve(handle);
|
|
if (result.code != Code::OK) {
|
|
return result;
|
|
}
|
|
const Impl::Slot &slot = impl_->slots[static_cast<std::size_t>(handle.slot)];
|
|
result.value = slot.value;
|
|
return result;
|
|
}
|
|
Resource Ledger::inspect(Integer slot) const {
|
|
return impl_->export_slot(slot);
|
|
}
|
|
Participant Ledger::actor(Integer participant) const {
|
|
return impl_->export_actor(participant);
|
|
}
|
|
Summary Ledger::summary() const {
|
|
Summary result;
|
|
for (const Impl::Slot &slot : impl_->slots) {
|
|
if (slot.active) {
|
|
result.active += 1;
|
|
}
|
|
if (slot.owner != -1) {
|
|
result.owners += 1;
|
|
}
|
|
result.waiting += static_cast<Integer>(slot.queue.size());
|
|
}
|
|
return result;
|
|
}
|
|
|
|
Reply Ledger::position(Handle handle, Integer participant) const {
|
|
Reply answer;
|
|
answer.code = impl_->resolve_actor(handle, participant);
|
|
if (answer.code != Code::OK) {
|
|
return answer;
|
|
}
|
|
const Impl::Slot &slot = impl_->slots[static_cast<std::size_t>(handle.slot)];
|
|
if (impl_->owns(slot, participant)) {
|
|
answer.value = -1;
|
|
return answer;
|
|
}
|
|
Integer index = 0;
|
|
for (Integer waiter : slot.queue) {
|
|
if (waiter == participant) {
|
|
answer.value = index;
|
|
return answer;
|
|
}
|
|
index += 1;
|
|
}
|
|
answer.code = Code::NOT_WAITING;
|
|
return answer;
|
|
}
|
|
}
|