in src/cpp/RiderLink/Source/RD/src/rd_framework_cpp/src/main/impl/RdMap.h [89:139]
void init(Lifetime lifetime) const override
{
RdBindableBase::init(lifetime);
local_change([this, lifetime]() {
advise(lifetime, [this, lifetime](Event e) {
if (!is_local_change)
return;
V const* new_value = e.get_new_value();
if (new_value)
{
const IProtocol* iProtocol = get_protocol();
const Identities* identity = iProtocol->get_identity();
identifyPolymorphic(*new_value, *identity, identity->next(rdid));
}
get_wire()->send(rdid, [this, e](Buffer& buffer) {
int32_t versionedFlag = ((is_master ? 1 : 0)) << versionedFlagShift;
Op op = static_cast<Op>(e.v.index());
buffer.write_integral<int32_t>(static_cast<int32_t>(op) | versionedFlag);
int64_t version = is_master ? ++next_version : 0L;
if (is_master)
{
pendingForAck.emplace(e.get_key(), version);
buffer.write_integral(version);
}
KS::write(this->get_serialization_context(), buffer, *e.get_key());
V const* new_value = e.get_new_value();
if (new_value)
{
VS::write(this->get_serialization_context(), buffer, *new_value);
}
spdlog::get("logSend")->trace("SEND{}", logmsg(op, next_version - 1, e.get_key(), new_value));
});
});
});
get_wire()->advise(lifetime, this);
if (!optimize_nested)
this->view(lifetime, [this](Lifetime lf, std::pair<K const*, V const*> entry) {
bindPolymorphic(entry.second, lf, this, "[" + to_string(*entry.first) + "]");
});
}