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>
82 lines
1.9 KiB
C++
82 lines
1.9 KiB
C++
#ifndef READER_CACHE_API_HPP
|
|
#define READER_CACHE_API_HPP
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <vector>
|
|
namespace readercache {
|
|
struct Event {
|
|
int kind;
|
|
int object;
|
|
int argument;
|
|
};
|
|
struct Resource {
|
|
bool allocated = false;
|
|
bool initialized = false;
|
|
int readers = 0;
|
|
bool writer = false;
|
|
};
|
|
class Pool {
|
|
public:
|
|
int allocate();
|
|
bool initialize(int object);
|
|
bool enter_reader(int object);
|
|
bool leave_reader(int object);
|
|
bool enter_writer(int object);
|
|
bool leave_writer(int object);
|
|
bool destroy(int object);
|
|
bool release(int object);
|
|
void fail_next_initialization();
|
|
void clear_events();
|
|
const std::vector<Event>& events() const;
|
|
std::vector<long long> counters() const;
|
|
private:
|
|
Resource* find(int object);
|
|
void record(int kind, int object, int argument);
|
|
bool reject(int kind, int object, int argument);
|
|
std::map<int, Resource> resources_;
|
|
std::vector<Event> events_;
|
|
int next_ = 1;
|
|
int allocated_ = 0;
|
|
int released_ = 0;
|
|
int initialized_ = 0;
|
|
int destroyed_ = 0;
|
|
int violations_ = 0;
|
|
bool fail_ = false;
|
|
};
|
|
struct View {
|
|
int handle;
|
|
int phase;
|
|
int resource;
|
|
long long value;
|
|
long long version;
|
|
int readers;
|
|
int writer;
|
|
};
|
|
struct Ticket {
|
|
int ticket;
|
|
int handle;
|
|
long long value;
|
|
long long version;
|
|
};
|
|
class Cache {
|
|
public:
|
|
explicit Cache(Pool& pool);
|
|
~Cache();
|
|
int create(int handle, long long initial);
|
|
int write(int handle, long long value);
|
|
int begin(int handle, int ticket, long long& value, long long& version);
|
|
int end(int ticket);
|
|
int close(int handle);
|
|
int start_write(int handle);
|
|
int commit(int handle, long long value);
|
|
int abort(int handle);
|
|
std::vector<View> views() const;
|
|
std::vector<Ticket> tickets() const;
|
|
private:
|
|
struct Impl;
|
|
std::unique_ptr<Impl> impl_;
|
|
};
|
|
}
|
|
#endif
|