#include "fiko/istakip/istemci.hpp" namespace fiko::istakip { uint64_t IsIstemci::yazKuyrukla(const IsKayit& taslak, uint64_t beklenenSurum) { const uint64_t sira = ++sonSira_; bekleyenler_.push_back({sira, taslak, beklenenSurum}); return sira; } void IsIstemci::snapshotUygula(const std::vector& kayitlar, uint64_t yeniSurum, uint64_t islenenSira) { for (const auto& k : kayitlar) onbellek_[k.kimlik] = k; if (yeniSurum > sonSurum_) sonSurum_ = yeniSurum; while (!bekleyenler_.empty() && bekleyenler_.front().sira <= islenenSira) bekleyenler_.pop_front(); if (islenenSira > sonSira_) sonSira_ = islenenSira; // kral bizden ilerideyse yetiş } void IsIstemci::deltaUygula(const IsKayit& k, uint64_t yazarNo, uint64_t yazarSira) { if (yazarNo == istemciNo_) { while (!bekleyenler_.empty() && bekleyenler_.front().sira <= yazarSira) bekleyenler_.pop_front(); } if (k.surum <= sonSurum_) return; // çift teslim onbellek_[k.kimlik] = k; sonSurum_ = k.surum; } void IsIstemci::onayUygula(uint64_t sira) { while (!bekleyenler_.empty() && bekleyenler_.front().sira <= sira) bekleyenler_.pop_front(); } void IsIstemci::bekleyenSil(uint64_t sira) { for (auto it = bekleyenler_.begin(); it != bekleyenler_.end(); ++it) if (it->sira == sira) { bekleyenler_.erase(it); return; } } const IsKayit* IsIstemci::bul(uint64_t kimlik) const { const auto it = onbellek_.find(kimlik); return it == onbellek_.end() ? nullptr : &it->second; } std::vector IsIstemci::turListe(const std::string& tur) const { std::vector sonuc; for (const auto& [kimlik, k] : onbellek_) if (!k.silindi && k.tur == tur) sonuc.push_back(&k); return sonuc; } } // namespace fiko::istakip