pub struct Freshness { /* private fields */ }Implementations§
Source§impl Freshness
impl Freshness
pub fn new(window: Duration) -> Self
Sourcepub fn building(&self) -> bool
pub fn building(&self) -> bool
Whether a refresh is writing to the index right now.
A read checks this rather than queueing behind the write: the index is one connection behind one mutex, and a chunk of a rebuild takes far longer than the notmuch call the reader would otherwise be waiting on, so blocking on it would make the index slower than not having one.
pub fn begin_build(&self)
pub fn end_build(&self)
Sourcepub fn fresh(&self) -> bool
pub fn fresh(&self) -> bool
Whether the index was confirmed current recently enough to be believed.
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Read before doing the work that makes the index current, and handed back
to Self::vouch afterwards.
Sourcepub fn vouch(&self, generation: u64)
pub fn vouch(&self, generation: u64)
Declares the index current — but only if nothing was written since
generation was taken.
A write that lands during a refresh is not in what that refresh read, so vouching for it unconditionally hides the write for a whole window: the tag is in notmuch, the list does not have it, and nothing anywhere is in an error state. It takes a build finishing in the same moment as a write, which is why it survived every run of the suite but one.
Sourcepub fn note_write(&self)
pub fn note_write(&self)
A write of ours moved the database, so the next read revalidates — and any refresh already in flight can no longer vouch for what it built.