mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-22 09:30:45 +00:00
The `raft_address_map` code was "clever": it used two intrusive data structures and did a lot of manual lifetime management; raw pointer manipulation, manual deletion of objects... It wasn't clear who owns which object, who is responsible for deleting what. And there was a lot of code. In this PR we replace one of the intrusive data structures with a good old `std::unordered_map` and make ownership clear by replacing the raw pointers with `std::unique_ptr`. Furthermore, some invariants which were not clear and enforced in runtime are now encoded in the type system. The code also became shorter: we reduced its length from ~360 LOC to ~260 LOC. Closes #11763 * github.com:scylladb/scylladb: service/raft: raft_address_map: get rid of `is_linked` checks service/raft: raft_address_map: get rid of `to_list_iterator` service/raft: raft_address_map: simplify ownership of `expiring_entry_ptr` service/raft: raft_address_map: move _last_accessed field from timestamped_entry to expiring_entry_ptr service/raft: raft_address_map: don't use intrusive set for timestamped entries service/raft: raft_address_map: store reference to `timestamped_entry` in `expiring_entry_ptr`