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>
104 lines
2.4 KiB
C++
104 lines
2.4 KiB
C++
#include "state.hpp"
|
|
namespace notify {
|
|
void Runtime::Impl::publish(int queue)
|
|
{
|
|
Slot& slot = slots[queue];
|
|
if (!slot.registration.present()) {
|
|
return;
|
|
}
|
|
Event event;
|
|
counters.notified += 1;
|
|
event.serial = counters.notified;
|
|
event.queue = queue;
|
|
event.owner = slot.registration.owner;
|
|
event.cookie = slot.registration.cookie;
|
|
events.push_back(event);
|
|
slot.registration.clear();
|
|
}
|
|
void Runtime::Impl::on_enqueue(int queue, bool was_empty)
|
|
{
|
|
if (!was_empty) {
|
|
return;
|
|
}
|
|
if (!slots[queue].registration.present()) {
|
|
return;
|
|
}
|
|
publish(queue);
|
|
}
|
|
void Runtime::Impl::register_owner(int queue, int owner, int cookie)
|
|
{
|
|
Slot& slot = slots[queue];
|
|
slot.registration.owner = owner;
|
|
slot.registration.cookie = cookie;
|
|
counters.armed += 1;
|
|
}
|
|
void Runtime::Impl::cancel_owner(int queue)
|
|
{
|
|
Slot& slot = slots[queue];
|
|
if (!slot.registration.present()) {
|
|
return;
|
|
}
|
|
slot.registration.clear();
|
|
counters.canceled += 1;
|
|
}
|
|
std::deque<Event>::iterator Runtime::Impl::find_event(int owner)
|
|
{
|
|
auto it = events.begin();
|
|
for (; it != events.end(); ++it) {
|
|
if (it->owner == owner) {
|
|
break;
|
|
}
|
|
}
|
|
return it;
|
|
}
|
|
std::deque<Event>::const_iterator Runtime::Impl::find_event(int owner) const
|
|
{
|
|
auto it = events.cbegin();
|
|
for (; it != events.cend(); ++it) {
|
|
if (it->owner == owner) {
|
|
break;
|
|
}
|
|
}
|
|
return it;
|
|
}
|
|
Result<Event> Runtime::Impl::event_result(int owner, bool consume)
|
|
{
|
|
Result<Event> output;
|
|
if (!owner_valid(owner)) {
|
|
output.code = Code::invalid;
|
|
return output;
|
|
}
|
|
auto it = find_event(owner);
|
|
if (it == events.end()) {
|
|
output.code = Code::empty;
|
|
return output;
|
|
}
|
|
output.value = *it;
|
|
if (consume) {
|
|
events.erase(it);
|
|
counters.claimed += 1;
|
|
}
|
|
return output;
|
|
}
|
|
Result<Event> Runtime::claim(int owner)
|
|
{
|
|
return impl_->event_result(owner, true);
|
|
}
|
|
Result<Event> Runtime::inspect(int owner) const
|
|
{
|
|
Result<Event> output;
|
|
if (!Impl::owner_valid(owner)) {
|
|
output.code = Code::invalid;
|
|
return output;
|
|
}
|
|
const Impl& state = *impl_;
|
|
auto it = state.find_event(owner);
|
|
if (it == state.events.end()) {
|
|
output.code = Code::empty;
|
|
return output;
|
|
}
|
|
output.value = *it;
|
|
return output;
|
|
}
|
|
}
|