Skip to main content

Module shared_entity

Module shared_entity 

Source
Expand description

Cached entities that share their fields between the views holding them.

Every view of an export receives the same patches, and a derived view holds the entity its source view holds, so most cached copies of one entity have the same fields. Each view’s frames carry their own _version (see the projector), which a view’s copy keeps, so the copies differ in that one field. A SharedEntity keeps every other field behind an Arc that the copies share, and _version beside it, per copy. A change replaces or copies the shared fields before it writes (copy-on-write), so it never reaches another holder’s copy.

The shared fields of an object are themselves shared one top-level field at a time (see [Fields]): copying them before a write copies a list of pointers, and the write then copies only the fields it changes. A patch to one section of a large entity costs that section, not the entity, and the old version, still held by a derived view or a subscriber, shares every other section with the new one. Dropping the old version frees only what the patch replaced.

Structs§

SharedEntity
One copy of a cached entity: fields shared with every other copy that has the same ones, plus this copy’s _version.

Constants§

VERSION_FIELD
The field each view’s copy of an entity stamps with its own frame version.

Traits§

EntityFields
Field access shared by plain values and SharedEntity copies.

Functions§

lookup
The value at path, field names from the top of entity; the whole entity for an empty path. None as soon as a step is missing.