module Pf::Core::IProbeAuthored

Overview

Includers can author a change in the trie, enabling them to later mutate the part of the trie they've already copied. See #author.

Direct including types

Defined in:

permafrost/core/node.cr

Instance Method Summary

Instance Method Detail

abstract def author : AuthorId #

Returns the id of the author of the proposed addition. The author is made the owner of the path-copied items and children arrays in the trie. Meaning further changes along the same route made by the same author will not produce copies; the author's done the job already.

Essentially #author is the "password" for mutating the resulting part of the trie. Completely new nodes give write access to both arrays to #author immediately.

The id must be unique across distinct edits of the trie (this is guaranteed by Pf::Map::Commit and Pf::Set::Commit; they are the main users of this feature). By using the analogy defined above, if more than one entity knows the password to edit the trie in-place, everything about immutability or exclusive write access is broken.

We never make full copies of the trie, not at the beginning, nor at the end. We only make copies of edited paths. When the edit sequence finishes, its author must be guaranteed to retire, as the trie is passed to the immutable interface as-is. So if the author does not retire and modifies the tree, the immutable version will change as well, which is not expected.

If unavailable, you can return AUTHOR_NONE.


[View source]